Skip to content

Commit

Permalink
[FIX] sale_margin_tax: handle translated cases
Browse files Browse the repository at this point in the history
  • Loading branch information
len-foss committed Jan 18, 2024
1 parent 80ba06a commit 9961424
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions sale_margin_tax/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import api, fields, models
from odoo import _, api, fields, models
from odoo.tools.misc import formatLang


Expand Down Expand Up @@ -132,12 +132,17 @@ def _prepare_tax_totals(self, base_lines, currency, tax_lines=None):
res = super()._prepare_tax_totals(base_lines, currency, tax_lines=tax_lines)
filtered_groups = []
hidden_taxes = 0
groups = res["groups_by_subtotal"].get("Untaxed Amount", [])
margin_group = self.env.ref("sale_margin_tax.tax_group_margin")
keys = list(res["groups_by_subtotal"].keys())

Check warning on line 136 in sale_margin_tax/models/account_tax.py

View check run for this annotation

Codecov / codecov/patch

sale_margin_tax/models/account_tax.py#L132-L136

Added lines #L132 - L136 were not covered by tests
if len(keys) == 1:
group_key = keys[0]

Check warning on line 138 in sale_margin_tax/models/account_tax.py

View check run for this annotation

Codecov / codecov/patch

sale_margin_tax/models/account_tax.py#L138

Added line #L138 was not covered by tests
else: # make sure we get the right one
# if someone changes the translation of Untaxed Amount inconsistently
# with the value in the account module, that would break
group_key = margin_group.preceding_subtotal or _("Untaxed Amount")
groups = res["groups_by_subtotal"].get(group_key, [])

Check warning on line 143 in sale_margin_tax/models/account_tax.py

View check run for this annotation

Codecov / codecov/patch

sale_margin_tax/models/account_tax.py#L142-L143

Added lines #L142 - L143 were not covered by tests
for group in groups:
if (
group["tax_group_id"]
!= self.env.ref("sale_margin_tax.tax_group_margin").id
):
if group["tax_group_id"] != margin_group.id:
filtered_groups.append(group)

Check warning on line 146 in sale_margin_tax/models/account_tax.py

View check run for this annotation

Codecov / codecov/patch

sale_margin_tax/models/account_tax.py#L146

Added line #L146 was not covered by tests
else:
hidden_taxes += group["tax_group_amount"]

Check warning on line 148 in sale_margin_tax/models/account_tax.py

View check run for this annotation

Codecov / codecov/patch

sale_margin_tax/models/account_tax.py#L148

Added line #L148 was not covered by tests
Expand Down

0 comments on commit 9961424

Please sign in to comment.