Hello Arif,
Thanks for your contribution. I just improved your code in order to remove the extra loop, and to use a flag instead of a list.
FYI, here is the patch i merged === modified file 'sale/sale.py' --- sale/sale.py 2012-02-15 17:32:52 +0000 +++ sale/sale.py 2012-02-16 16:22:11 +0000 @@ -147,11 +147,14 @@ 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
« Back to merge proposal
Hello Arif,
Thanks for your contribution. I just improved your code in order to remove the extra loop, and to use a flag instead of a list.
FYI, here is the patch i merged
res[ sale.id] = True
res[ sale.id
=== modified file 'sale/sale.py'
--- sale/sale.py 2012-02-15 17:32:52 +0000
+++ sale/sale.py 2012-02-16 16:22:11 +0000
@@ -147,11 +147,14 @@
res = {}
for sale in self.browse(cursor, user, ids, context=context):
+ 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: