From 8e82e83f86f250f7fded16ef84580e699357d1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 4 Mar 2025 22:05:19 +0100 Subject: [PATCH] Remove only lot expiring in the future Closes #13901 (grafted from 54977ca200c0448d05cb19ba43c6dbff45742e4a) --HG-- branch : 8.0 --- modules/stock_lot_sled/stock.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/stock_lot_sled/stock.py b/modules/stock_lot_sled/stock.py index cfe1db6bf6..247256e9c2 100644 --- a/modules/stock_lot_sled/stock.py +++ b/modules/stock_lot_sled/stock.py @@ -320,7 +320,8 @@ class Move(metaclass=PoolMeta): if add_join(sub_query.from_, lot): clause = ( (lot.shelf_life_expiration_date == Null) - | (lot.shelf_life_expiration_date >= expiration_date)) + | (lot.shelf_life_expiration_date >= expiration_date) + | (lot.shelf_life_expiration_date < today)) if sub_query.where: sub_query.where &= clause else: @@ -338,10 +339,11 @@ class Move(metaclass=PoolMeta): for sub_query in find_queries(union_expired): lot = Lot.__table__() if add_join(sub_query.from_, lot): - # only lot expiring during the period + # only lot expiring during the future part of the + # period clause = ( (lot.shelf_life_expiration_date - >= stock_date_start) + >= max(stock_date_start, today)) & (lot.shelf_life_expiration_date < stock_date_end)) if sub_query.where: