From b8a10a5324e5d17f06e1efd621f6edb0c68bb2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 16 Mar 2014 15:39:22 +0100 Subject: [PATCH] Be safer with the on_change using One2Many values review4261002 --- invoice.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/invoice.py b/invoice.py index 90cf07893d..a34c94e4b5 100644 --- a/invoice.py +++ b/invoice.py @@ -451,11 +451,11 @@ class Invoice(Workflow, ModelSQL, ModelView): for line in self.lines: if (line.type or 'line') != 'line': continue - res['untaxed_amount'] += line.amount or 0 + res['untaxed_amount'] += getattr(line, 'amount', None) or 0 with Transaction().set_context(**context): - taxes = Tax.compute(line.taxes, - line.unit_price or Decimal('0.0'), - line.quantity or 0.0, + taxes = Tax.compute(getattr(line, 'taxes', []) or [], + getattr(line, 'unit_price', None) or Decimal('0.0'), + getattr(line, 'quantity', None) or 0.0, date=self.accounting_date or self.invoice_date) for tax in taxes: key, val = self._compute_tax(tax,