From fb274af86f9cecae3370d34333b077b5436bc225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 16 Mar 2014 15:39:58 +0100 Subject: [PATCH] Be safer with the on_change using One2Many values review4261002 --- statement.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/statement.py b/statement.py index f1db7c82a4..ec9d9725f7 100644 --- a/statement.py +++ b/statement.py @@ -206,7 +206,7 @@ class Statement(Workflow, ModelSQL, ModelView): if self.journal and self.lines: invoices = set() for line in self.lines: - if line.invoice: + if getattr(line, 'invoice', None): invoices.add(line.invoice) invoice_id2amount_to_pay = {} for invoice in invoices: @@ -220,10 +220,11 @@ class Statement(Workflow, ModelSQL, ModelView): invoice.amount_to_pay, self.journal.currency)) for line in self.lines or []: - if line.invoice and line.id: + if getattr(line, 'invoice', None) and line.id: amount_to_pay = invoice_id2amount_to_pay[line.invoice.id] res['lines'].setdefault('update', []) if (not self.journal.currency.is_zero(amount_to_pay) + and getattr(line, 'amount', None) and (line.amount >= 0) == (amount_to_pay <= 0)): res['lines']['update'].append({ 'id': line.id,