Fee rules

This commit is contained in:
2026-05-25 13:51:55 +02:00
parent 436d0b9a0c
commit 12727e53cb
4 changed files with 11 additions and 6 deletions

View File

@@ -993,7 +993,7 @@ class FeeRule(ModelSQL, ModelView):
party = fields.Many2One('party.party', "Counterparty")
line_product = fields.Many2One('product.product', "Line Product")
incoterm = fields.Many2One('incoterm.incoterm', "Incoterm")
incoterm_code = fields.Char("Incoterm Code")
from_location = fields.Many2One('stock.location', "From Location")
to_location = fields.Many2One('stock.location', "To Location")
execution_plan = fields.Many2One('workflow.plan', "Execution Plan")
@@ -1071,13 +1071,17 @@ class FeeRule(ModelSQL, ModelView):
checks = [
(self.party, getattr(contract, 'party', None)),
(self.line_product, getattr(line, 'product', None)),
(self.incoterm, getattr(contract, 'incoterm', None)),
(self.from_location, getattr(contract, 'from_location', None)),
(self.to_location, getattr(contract, 'to_location', None)),
]
if any(rule_value and not self._same_record(rule_value, actual)
for rule_value, actual in checks):
return False
if self.incoterm_code:
incoterm = getattr(contract, 'incoterm', None)
if (getattr(incoterm, 'code', '') or '').upper() != (
self.incoterm_code or '').upper():
return False
if self.execution_plan and not self._same_record(
self.execution_plan, getattr(contract, 'plan', None)):
return False

View File

@@ -1804,7 +1804,8 @@ class PurchaseTradeTestCase(ModuleTestCase):
rule.apply_on = 'purchase_line'
rule.party = party
rule.line_product = product
rule.incoterm = incoterm
rule.incoterm_code = 'FOB'
incoterm.code = 'FOB'
rule.from_location = from_location
rule.to_location = to_location
rule.execution_plan = plan

View File

@@ -14,8 +14,8 @@
<field name="party"/>
<label name="line_product"/>
<field name="line_product"/>
<label name="incoterm"/>
<field name="incoterm"/>
<label name="incoterm_code"/>
<field name="incoterm_code"/>
<label name="from_location"/>
<field name="from_location"/>
<label name="to_location"/>

View File

@@ -6,7 +6,7 @@
<field name="auto_apply"/>
<field name="party"/>
<field name="line_product"/>
<field name="incoterm"/>
<field name="incoterm_code"/>
<field name="from_location"/>
<field name="to_location"/>
<field name="fee_product"/>