Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] account: compute tax ordering #156024

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/account/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def flatten_taxes_hierarchy(self, create_map=False):
# mapping each child tax to its parent group
all_taxes = self.env['account.tax']
groups_map = {}
for tax in self.sorted(key=lambda r: r.sequence):
for tax in self.sorted(key=lambda r: (r.sequence, r._origin.id)):
if tax.amount_type == 'group':
flattened_children = tax.children_tax_ids.flatten_taxes_hierarchy()
all_taxes += flattened_children
Expand Down
1 change: 1 addition & 0 deletions addons/account/tests/test_account_move_in_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def setUpClass(cls, chart_template_ref=None):
'amount_total': 1128.0,
}
cls.env.user.groups_id += cls.env.ref('uom.group_uom')
(cls.tax_armageddon + cls.tax_armageddon.children_tax_ids).write({'type_tax_use': 'purchase'})

def setUp(self):
super(TestAccountMoveInInvoiceOnchanges, self).setUp()
Expand Down
1 change: 1 addition & 0 deletions addons/account/tests/test_account_move_in_refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def setUpClass(cls, chart_template_ref=None):
'amount_tax': 168.0,
'amount_total': 1128.0,
}
(cls.tax_armageddon + cls.tax_armageddon.children_tax_ids).write({'type_tax_use': 'purchase'})

def setUp(self):
super(TestAccountMoveInRefundOnchanges, self).setUp()
Expand Down
3 changes: 3 additions & 0 deletions addons/account/tests/test_invoice_tax_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,15 @@ def test_tax_affect_base_2(self):
'amount': 10.0,
'tax_group_id': self.tax_group1.id,
'include_base_amount': True,
'sequence': 2,
})

tax_20 = self.env['account.tax'].create({
'name': "tax_20",
'amount_type': 'percent',
'amount': 20.0,
'tax_group_id': self.tax_group1.id,
'sequence': 2,
})

tax_30 = self.env['account.tax'].create({
Expand All @@ -325,6 +327,7 @@ def test_tax_affect_base_2(self):
'amount': 30.0,
'tax_group_id': self.tax_group2.id,
'include_base_amount': True,
'sequence': 1,
})

document = self._create_document_for_tax_totals_test([
Expand Down
5 changes: 3 additions & 2 deletions addons/account/tests/test_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,8 @@ def test_rounding_tax_included_round_per_line_02(self):
)

def test_rounding_tax_included_round_per_line_03(self):
''' Test the rounding of a 8% and 0% price included tax in an invoice having 8 * 15.55 as line.
''' Test the rounding of a 8% and 0% price included tax in an invoice having 8 * 15.55 as line
and a sequence that is solely dependent on the ID, as the tax sequence is identical.
The decimal precision is set to 2.
'''
self.tax_0_percent.company_id.currency_id.rounding = 0.01
Expand All @@ -877,8 +878,8 @@ def test_rounding_tax_included_round_per_line_03(self):
[
# base , amount
# -------------
(115.19, 9.21),
(115.19, 0.00),
(115.19, 9.21),
# -------------
],
res1
Expand Down
3 changes: 2 additions & 1 deletion addons/account_tax_python/tests/test_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def test_tax_python_price_include(self):
res
)

res = (self.python_tax + self.python_tax).compute_all(130.0)
python_tax_2 = self.python_tax.copy()
res = (self.python_tax + python_tax_2).compute_all(130.0)
self._check_compute_all_results(
130, # 'total_included'
116.07, # 'total_excluded'
Expand Down