Skip to content

Commit

Permalink
[IMP] sale_margin_tax: copy all tax values
Browse files Browse the repository at this point in the history
  • Loading branch information
len-foss committed Apr 15, 2024
1 parent a561000 commit 3f3c9d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sale_margin_tax/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _get_or_create_margin_tax(self, base_amount, margin):
vals["name"] = self._get_margin_tax_name(tax_percent)
desc_template = self.margin_description_template or ""
vals["description"] = desc_template.format(tax_percent)
tax = Tax.create(vals)
tax = self.copy(vals)
return tax

def _get_margin_tax_name(self, tax_percent):
Expand Down
12 changes: 12 additions & 0 deletions sale_margin_tax/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ def setUpClass(cls):
vals_tax_other = {"name": "Other Tax", "amount": 21.0, "amount_type": "percent"}
cls.tax_other = cls.env["account.tax"].create(vals_tax_other)

vals_tag_vat = {"name": "VAT", "applicability": "taxes"}
cls.tag_vat = cls.env["account.account.tag"].create(vals_tag_vat)
vals_tag_base = {"name": "Base", "applicability": "taxes"}
cls.tag_base = cls.env["account.account.tag"].create(vals_tag_base)
cls.tags = cls.tag_base + cls.tag_vat

lines = cls.tax_margin.invoice_repartition_line_ids
line_base = lines.filtered(lambda l: l.repartition_type == "base")
line_margin = lines.filtered(lambda l: l.repartition_type == "tax")
line_base.tag_ids = [(6, 0, cls.tag_base.ids)]
line_margin.tag_ids = [(6, 0, cls.tag_vat.ids)]

vals_sale = {
"partner_id": cls.partner.id,
"partner_invoice_id": cls.partner.id,
Expand Down
3 changes: 3 additions & 0 deletions sale_margin_tax/tests/test_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def test_sale_invoice_tax(self):
self.assertEqual(invoice.amount_total, 115)
self.assertTrue("marg" in invoice.narration)

# then: tax tags are properly copied from the margin tax
self.assertEqual(invoice.line_ids.tax_tag_ids, self.tags)

def test_mixed_taxes(self):
"""First line has normal tax, other is on margin"""
# given:
Expand Down

0 comments on commit 3f3c9d2

Please sign in to comment.