From ea2dbe21d5b15caa76d5e5279f7c139cfbc272ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 12 Dec 2023 16:03:33 +0100 Subject: [PATCH] Check lot required only when changing move to done Closes #12547 --- modules/stock_lot/stock.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/stock_lot/stock.py b/modules/stock_lot/stock.py index 30bc673190..fe74a65181 100644 --- a/modules/stock_lot/stock.py +++ b/modules/stock_lot/stock.py @@ -448,8 +448,7 @@ class Move(metaclass=PoolMeta): def check_lot(self): "Check if lot is required" - if (self.state == 'done' - and self.internal_quantity + if (self.internal_quantity and not self.lot and self.product.lot_is_required( self.from_location, self.to_location)): @@ -458,8 +457,9 @@ class Move(metaclass=PoolMeta): product=self.product.rec_name)) @classmethod - def validate(cls, moves): - super(Move, cls).validate(moves) + @ModelView.button + def do(cls, moves): + super().do(moves) for move in moves: move.check_lot()