Allow selecting blanket agreement line without supplier/customer product

When the order line as a supplier/customer product, we should allow to select
blanket agreement line with the same product or without any product. Because
the supplier/customer product may be added after the blanket agreement is
running.

Closes #12909
This commit is contained in:
Cédric Krier
2024-01-08 14:28:38 +01:00
parent 88b26a7eb6
commit 78abed9f25
2 changed files with 27 additions and 7 deletions
+13 -5
View File
@@ -767,8 +767,11 @@ class Line(metaclass=PoolMeta):
return [
('product', '=', Eval('product', -1)),
If(Eval('product_supplier'),
('product_supplier', '=', Eval('product_supplier')),
()),
['OR',
('product_supplier', '=', Eval('product_supplier')),
('product_supplier', '=', None),
],
[]),
]
@fields.depends(
@@ -820,11 +823,16 @@ class Line(metaclass=PoolMeta):
self.blanket_agreement_line = None
@fields.depends(
'blanket_agreement_line', 'product',
'_parent_blanket_agreement_line.product')
'blanket_agreement_line', 'product', 'product_supplier',
'_parent_blanket_agreement_line.product',
'_parent_blanket_agreement_line.product_supplier')
def is_valid_product_for_blanket_agreement(self):
if self.blanket_agreement_line:
return self.product == self.blanket_agreement_line.product
return (self.product == self.blanket_agreement_line.product
and (
(self.product_supplier
== self.blanket_agreement_line.product_supplier)
or not self.product_supplier))
def quantity_for_blanket_agreement(self, line, round=True):
pool = Pool()
+14 -2
View File
@@ -128,8 +128,11 @@ class LineBlanketAgreement(metaclass=PoolMeta):
return [
super()._domain_blanket_agreemnt_line_product(),
If(Eval('product_customer'),
('product_customer', '=', Eval('product_customer')),
()),
['OR',
('product_customer', '=', Eval('product_customer')),
('product_customer', '=', None),
],
[]),
]
@fields.depends(
@@ -142,6 +145,15 @@ class LineBlanketAgreement(metaclass=PoolMeta):
self.product_customer = line.product_customer
super().on_change_blanket_agreement_line()
@fields.depends(
'product_customer', '_parent_blanket_agreement_line.product_customer')
def is_valid_product_for_blanket_agreement(self):
return (super().is_valid_product_for_blanket_agreement()
and (
(self.product_customer
== self.blanket_agreement_line.product_customer)
or not self.product_customer))
class BlanketAgreementLine(metaclass=PoolMeta):
__name__ = 'sale.blanket_agreement.line'