[MERGE] lp:929373. Courtesy of Arif
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Thu, 16 Feb 2012 16:52:53 +0000 (17:52 +0100)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Thu, 16 Feb 2012 16:52:53 +0000 (17:52 +0100)
bzr revid: qdp-launchpad@openerp.com-20120216165253-01d70hrlf8pmnn7x

addons/sale/sale.py

index 99d2e49..82bfda7 100644 (file)
@@ -147,11 +147,14 @@ class sale_order(osv.osv):
         res = {}
         for sale in self.browse(cursor, user, ids, context=context):
             res[sale.id] = True
+            invoice_existence = False
             for invoice in sale.invoice_ids:
-                if invoice.state != 'paid':
-                    res[sale.id] = False
-                    break
-            if not sale.invoice_ids:
+                if invoice.state!='cancel':
+                    invoice_existence = True
+                    if invoice.state != 'paid':
+                        res[sale.id] = False
+                        break
+            if not invoice_existence:
                 res[sale.id] = False
         return res