Enforce the same category of UoM for move with a sale line as origin

The sale line computes the remaining quantity and the quantity to invoice by
converting the move quantity to the sale unit. So they must have the same
category of UoM.

issue6839
review35691002
This commit is contained in:
Cédric Krier
2017-10-18 14:51:12 +02:00
parent 6407bfe647
commit 571f003055
+12
View File
@@ -178,6 +178,18 @@ class Move:
return 'ignored'
return ''
@fields.depends('origin')
def on_change_with_product_uom_category(self, name=None):
pool = Pool()
SaleLine = pool.get('sale.line')
category = super(Move, self).on_change_with_product_uom_category(
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):
category = self.origin.unit.category.id
return category
@property
def origin_name(self):
pool = Pool()