Prevent the provisioning and overflowing locations from being a child of the order point location

Closes #12410 #14196
This commit is contained in:
Cédric Krier
2026-09-22 09:47:03 +02:00
parent eb49ec2c47
commit efed804e60
2 changed files with 33 additions and 8 deletions
+2 -6
View File
@@ -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']
+31 -2
View File
@@ -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__()