From 1eec89be7ce68aedf22430582bef604d739ffb8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 16 Mar 2014 15:45:25 +0100 Subject: [PATCH] Be safer with the on_change using One2Many values review4261002 --- sale.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sale.py b/sale.py index 10cda28cd5..b4aafc36bd 100644 --- a/sale.py +++ b/sale.py @@ -85,7 +85,7 @@ class Sale: cost_line = {} products = [line.product for line in self.lines or [] - if line.product] + if getattr(line, 'product', None)] stockable = any(product.type in ('goods', 'assets') for product in products) if cost and currency_id and stockable: @@ -128,12 +128,13 @@ class Sale: if not self.lines: self.lines = [] for line in self.lines: - if line.shipment_cost: + if getattr(line, 'shipment_cost', None): if line.shipment_cost != cost_line.get('shipment_cost'): to_remove = line.id self.lines.remove(line) if cost_line: - cost_line['description'] = line.description + cost_line['description'] = getattr(line, 'description', + '') else: cost_line = {} break