[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

1  2 
addons/sale/sale.py

@@@ -147,11 -147,15 +147,14 @@@ class sale_order(osv.osv)
          res = {}
          for sale in self.browse(cursor, user, ids, context=context):
              res[sale.id] = True
 -            invoices = []
++            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':
 -                    invoices.append(invoice)
 -            for invoice in invoices: 
 -                if invoice.state != 'paid':
 -                    res[sale.id] = False
 -                    break
 -            if not invoices:
++                    invoice_existence = True
++                    if invoice.state != 'paid':
++                        res[sale.id] = False
++                        break
++            if not invoice_existence:
                  res[sale.id] = False
          return res