From 0bcab14bf47f76faf79070054f35ede80aa2b3cf Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Fri, 26 Jun 2026 19:04:26 +0200 Subject: [PATCH] Use the effective date of the stock move to generate sequence when creating lot Closes #14899 (grafted from e5f7e95553a42dc02ac9ea57002523bc87471353) --HG-- branch : 8.0 --- modules/production/production.py | 4 +++- modules/stock_lot/stock.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/production/production.py b/modules/production/production.py index e0ea63689f..aa15ed8327 100644 --- a/modules/production/production.py +++ b/modules/production/production.py @@ -897,7 +897,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 f981718422..6a8a1c33e1 100644 --- a/modules/stock_lot/stock.py +++ b/modules/stock_lot/stock.py @@ -436,8 +436,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