details: https://code.tryton.org/tryton/commit/9e5684afd83d
branch: 7.8
user: Sergi Almacellas Abellana <[email protected]>
date: Fri Jun 26 19:04:26 2026 +0200
description:
Use the effective date of the stock move to generate sequence when
creating lot
Closes #14899
(grafted from e5f7e95553a42dc02ac9ea57002523bc87471353)
diffstat:
modules/production/production.py | 4 +++-
modules/stock_lot/stock.py | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diffs (30 lines):
diff -r 697ec4b1e6d1 -r 9e5684afd83d modules/production/production.py
--- a/modules/production/production.py Tue Jun 16 13:41:49 2026 +0200
+++ b/modules/production/production.py Fri Jun 26 19:04:26 2026 +0200
@@ -903,7 +903,9 @@
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 -r 697ec4b1e6d1 -r 9e5684afd83d modules/stock_lot/stock.py
--- a/modules/stock_lot/stock.py Tue Jun 16 13:41:49 2026 +0200
+++ b/modules/stock_lot/stock.py Fri Jun 26 19:04:26 2026 +0200
@@ -442,8 +442,11 @@
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