details:   https://code.tryton.org/tryton/commit/49a08bec75e1
branch:    8.2
user:      Cédric Krier <[email protected]>
date:      Fri Oct 30 09:31:43 2026 +0100
description:
        Do not test the locations for other variants when setting stock move 
locations

        Closes #15203
        (grafted from 8bbb83c3f4d68f45bdd8f4a6893ef75c5349b4ca)
diffstat:

 modules/stock_product_location/location.py |   3 +--
 modules/stock_product_location/product.py  |  11 +++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 1c0b002d3167 -r 49a08bec75e1 modules/stock_product_location/location.py
--- a/modules/stock_product_location/location.py        Fri Oct 30 10:18:56 
2026 +0100
+++ b/modules/stock_product_location/location.py        Fri Oct 30 09:31:43 
2026 +0100
@@ -67,8 +67,7 @@
             pattern.setdefault('template', self.product.template.id)
             pattern.setdefault('product', self.product.id)
 
-        locations = self.product.locations + self.product.template.locations
-        for product_location in locations:
+        for product_location in self.product.locations_used:
             if product_location.match(pattern):
                 return product_location.location
 
diff -r 1c0b002d3167 -r 49a08bec75e1 modules/stock_product_location/product.py
--- a/modules/stock_product_location/product.py Fri Oct 30 10:18:56 2026 +0100
+++ b/modules/stock_product_location/product.py Fri Oct 30 09:31:43 2026 +0100
@@ -15,6 +15,10 @@
             'invisible': ~Eval('type').in_(['goods', 'assets']),
             })
 
+    @property
+    def locations_used(self):
+        yield from self.locations
+
 
 class Product(copy_product_filtered('locations'), metaclass=PoolMeta):
     __name__ = 'product.product'
@@ -26,3 +30,10 @@
         states={
             'invisible': ~Eval('type').in_(['goods', 'assets']),
             })
+
+    @property
+    def locations_used(self):
+        yield from self.locations
+        for location in self.template.locations_used:
+            if not location.product:
+                yield location

Reply via email to