diff --git a/modules/production/production.py b/modules/production/production.py index 510db101fb..6424d07398 100644 --- a/modules/production/production.py +++ b/modules/production/production.py @@ -874,7 +874,9 @@ class Production_Lot(metaclass=PoolMeta): for move in production.outputs: if not move.lot and move.product.lot_is_required( move.from_location, move.to_location): - move.add_lot() + date = move.effective_date or production.effective_date + with Transaction().set_context(date=date): + move.add_lot() if move.lot: lots.append(move.lot) moves.append(move) diff --git a/modules/stock_lot/stock.py b/modules/stock_lot/stock.py index 304e7e7995..6db23ab055 100644 --- a/modules/stock_lot/stock.py +++ b/modules/stock_lot/stock.py @@ -441,8 +441,11 @@ class Move(metaclass=PoolMeta): pass def add_lot(self): + transaction = Transaction() if not self.lot and self.product: - lot = self.product.create_lot() + date = transaction.context.get('date') or self.effective_date + with Transaction().set_context(date=date): + lot = self.product.create_lot() if lot: self.lot = lot