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
This commit is contained in:
Cédric Krier committed 2018-04-21 12:55:59 +02:00
1 parent ab1b59a15e
commit ad0a7bebdf
1 file changed
+3 -1
+3 -1
View File
@@ -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