Meera Trambadia (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-799083-mtr into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #799083 in OpenERP Addons: "sales line not invoiced after moving the 
delivery into another delivery order"
  https://bugs.launchpad.net/openobject-addons/+bug/799083

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-799083-mtr/+merge/67151

sale:-sales line are now invoiced after moving the delivery into another 
delivery order --fixes=lp:799083 
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-799083-mtr/+merge/67151
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-799083-mtr.
=== modified file 'sale/sale.py'
--- sale/sale.py	2011-07-06 14:56:44 +0000
+++ sale/sale.py	2011-07-07 09:56:38 +0000
@@ -144,6 +144,8 @@
 
     def _invoiced(self, cursor, user, ids, name, arg, context=None):
         res = {}
+        invoice_obj = self.pool.get('account.invoice')
+        invoice_line_obj = self.pool.get('account.invoice.line')
         for sale in self.browse(cursor, user, ids, context=context):
             res[sale.id] = True
             for invoice in sale.invoice_ids:
@@ -152,6 +154,16 @@
                     break
             if not sale.invoice_ids:
                 res[sale.id] = False
+                if sale.state not in ('draft', 'cancel'):
+                    ids = [line.id for line in sale.order_line]
+                    cursor.execute('SELECT invoice_id from sale_order_line_invoice_rel where order_line_id IN %s' ,(tuple(ids),))
+                    result = map(lambda x: x[0], cursor.fetchall())
+                    if result: 
+                        invoice_ids = [invoice_line.invoice_id for invoice_line in invoice_line_obj.browse(cursor, user, result, context=context)]
+                        invoice_id = [invoice.id for invoice in invoice_ids if invoice_ids]
+                        for invoice in invoice_obj.browse(cursor, user, invoice_id, context=context):
+                            if invoice.state == 'paid':
+                                res[sale.id] = True     
         return res
 
     def _invoiced_search(self, cursor, user, obj, name, args, context=None):

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to