details:   https://code.tryton.org/tryton/commit/2cbcc90947d1
branch:    7.0
user:      Cédric Krier <[email protected]>
date:      Tue Mar 04 22:05:19 2025 +0100
description:
        Remove only lot expiring in the future

        Closes #13901
        (grafted from 54977ca200c0448d05cb19ba43c6dbff45742e4a)
diffstat:

 modules/stock_lot_sled/stock.py |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 7d6d7651c3e9 -r 2cbcc90947d1 modules/stock_lot_sled/stock.py
--- a/modules/stock_lot_sled/stock.py   Wed Jul 08 14:59:54 2026 +0200
+++ b/modules/stock_lot_sled/stock.py   Tue Mar 04 22:05:19 2025 +0100
@@ -325,7 +325,8 @@
                 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:
@@ -343,10 +344,11 @@
                     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:

Reply via email to