From ad0a7bebdfc9a824afb4b65452806dfea9afd0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 21 Apr 2018 12:55:59 +0200 Subject: [PATCH] Use getattr on Reference field The Reference field can have a negative id and so it does not have a value for all columns. issue7378 review47371002 --- stock.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stock.py b/stock.py index edff36465c..1e8fbb0741 100644 --- a/stock.py +++ b/stock.py @@ -186,7 +186,9 @@ class Move: name=name) # Enforce the same unit category as they are used to compute the # remaining quantity to ship and the quantity to invoice. - if isinstance(self.origin, SaleLine) and self.origin.unit: + # Use getattr as reference field can have negative id + if (isinstance(self.origin, SaleLine) + and getattr(self.origin, 'unit', None)): category = self.origin.unit.category.id return category