From efed804e603e015ec0351c40fc5be3354efa0600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 22 Sep 2026 09:47:03 +0200 Subject: [PATCH] Prevent the provisioning and overflowing locations from being a child of the order point location Closes #12410 #14196 --- modules/stock_consignment/stock.py | 8 ++----- modules/stock_supply/order_point.py | 33 +++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/modules/stock_consignment/stock.py b/modules/stock_consignment/stock.py index 3e1cdfb100..7d8e15bb1a 100644 --- a/modules/stock_consignment/stock.py +++ b/modules/stock_consignment/stock.py @@ -383,9 +383,5 @@ class OrderPoint(metaclass=PoolMeta): __name__ = 'stock.order_point' @classmethod - def __setup__(cls): - super().__setup__() - cls.provisioning_location.domain = ['OR', - cls.provisioning_location.domain, - ('type', '=', 'supplier'), - ] + def _provisioning_types(cls): + return super()._provisioning_types() + ['supplier'] diff --git a/modules/stock_supply/order_point.py b/modules/stock_supply/order_point.py index 9d82ed9a05..9dddc8490b 100644 --- a/modules/stock_supply/order_point.py +++ b/modules/stock_supply/order_point.py @@ -42,7 +42,13 @@ class OrderPoint(ModelSQL, ModelView): ]) provisioning_location = fields.Many2One( 'stock.location', 'Provisioning Location', - domain=[('type', 'in', ['storage', 'view'])], + domain=[ + ['OR', + ('provisioning_location', '=', None), + ('provisioning_location.parent', + 'not child_of', [Eval('location', -1)]), + ], + ], states={ 'invisible': Eval('type') != 'internal', 'required': ((Eval('type') == 'internal') @@ -50,7 +56,13 @@ class OrderPoint(ModelSQL, ModelView): }) overflowing_location = fields.Many2One( 'stock.location', 'Overflowing Location', - domain=[('type', 'in', ['storage', 'view'])], + domain=[ + ['OR', + ('overflowing_location', '=', None), + ('overflowing_location.parent', + 'not child_of', [Eval('location', -1)]), + ], + ], states={ 'invisible': Eval('type') != 'internal', 'required': ((Eval('type') == 'internal') @@ -117,6 +129,23 @@ class OrderPoint(ModelSQL, ModelView): Unique(t, t.product, t.location, t.company), 'stock_supply.msg_order_point_unique')) + cls.provisioning_location.domain = [ + cls.provisioning_location.domain, + ('type', 'in', cls._provisioning_types()), + ] + cls.overflowing_location.domain = [ + cls.overflowing_location.domain, + ('type', 'in', cls._overflowing_types()), + ] + + @classmethod + def _provisioning_types(cls): + return ['storage', 'view'] + + @classmethod + def _overflowing_types(cls): + return ['storage', 'view'] + @classmethod def __register__(cls, module): table = cls.__table__()