From 571f003055eb039211ef3e4e524d39da6449fc6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 18 Oct 2017 14:51:12 +0200 Subject: [PATCH] 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 --- stock.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stock.py b/stock.py index f60be8836a..230139111f 100644 --- a/stock.py +++ b/stock.py @@ -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()