From 12727e53cb5ad3ea51d0e3a230e77bf34762b417 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Mon, 25 May 2026 13:51:55 +0200 Subject: [PATCH] Fee rules --- modules/purchase_trade/fee.py | 8 ++++++-- modules/purchase_trade/tests/test_module.py | 3 ++- modules/purchase_trade/view/fee_rule_form.xml | 4 ++-- modules/purchase_trade/view/fee_rule_tree.xml | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/purchase_trade/fee.py b/modules/purchase_trade/fee.py index c2fa3fc..677ecc0 100755 --- a/modules/purchase_trade/fee.py +++ b/modules/purchase_trade/fee.py @@ -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 diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index 94aeb67..5931533 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -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 diff --git a/modules/purchase_trade/view/fee_rule_form.xml b/modules/purchase_trade/view/fee_rule_form.xml index 7860cdb..7c4dd85 100644 --- a/modules/purchase_trade/view/fee_rule_form.xml +++ b/modules/purchase_trade/view/fee_rule_form.xml @@ -14,8 +14,8 @@