From 502e2d5ecb7d7bb12de28a992b86e5287f6fbb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Mon, 16 Mar 2026 15:54:38 +0100 Subject: [PATCH] Create a hook to compute the reverse tax and amount from the tax type Closes #14681 --- modules/account/tax.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/account/tax.py b/modules/account/tax.py index d5d9b67eb3..db2055893e 100644 --- a/modules/account/tax.py +++ b/modules/account/tax.py @@ -1020,6 +1020,14 @@ class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin): price_unit += unit_price_variation return res + def _reverse_rate_amount_from_type(self, rate, amount): + if self.type == 'percentage': + return rate + self.rate, amount + elif self.type == 'fixed': + return rate, amount + self.amount + elif self.type == 'none': + return rate, amount + @classmethod def _reverse_rate_amount(cls, taxes, date): rate, amount = 0, 0 @@ -1029,10 +1037,7 @@ class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin): if not (start_date <= date <= end_date): continue - if tax.type == 'percentage': - rate += tax.rate - elif tax.type == 'fixed': - amount += tax.amount + rate, amount = tax._reverse_rate_amount_from_type(rate, amount) if tax.childs: child_rate, child_amount = cls._reverse_rate_amount(