details:   https://code.tryton.org/tryton/commit/3c617b318562
branch:    7.0
user:      Sergi Almacellas Abellana <[email protected]>
date:      Sat Oct 25 12:24:26 2025 +0200
description:
        Only delete requested shipments from the warehouses when supplying 
internal shipments

        Closes #14263
        (grafted from 30c128ddffacc3ae5a6a8577b9f9985b00cc9426)
diffstat:

 modules/stock_supply/shipment.py |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (35 lines):

diff -r 895004448b89 -r 3c617b318562 modules/stock_supply/shipment.py
--- a/modules/stock_supply/shipment.py  Tue Jul 29 09:25:00 2025 +0200
+++ b/modules/stock_supply/shipment.py  Sat Oct 25 12:24:26 2025 +0200
@@ -32,20 +32,26 @@
         if not company:
             return
 
+        clean_request_domain = [
+                ('state', '=', 'request'),
+                ('company', '=', company.id),
+                ]
         if warehouses is None:
             warehouses = Location.search([
                     ('type', '=', 'warehouse'),
                     ])
+        else:
+            clean_request_domain.append(
+                    ['OR',
+                        ('to_location.parent', 'child_of', warehouses),
+                        ('from_location.parent', 'child_of', warehouses),
+                        ])
 
         today = Date.today()
         lead_time = LeadTime.get_max_lead_time()
 
         if clean:
-            reqs = cls.search([
-                    ('state', '=', 'request'),
-                    ('company', '=', company.id),
-                    ])
-            cls.delete(reqs)
+            cls.delete(cls.search(clean_request_domain))
 
         # fetch quantities on order points
         order_points = OrderPoint.search([

Reply via email to