diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 00161ddb7d0..1a63589d804 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -889,6 +889,7 @@ class AccountMoveLine(models.Model): 'tax_tag_ids': [(6, 0, line.tax_tag_ids.ids)], 'partner_id': line.partner_id.id, 'move_id': line.move_id.id, + 'display_type': line.display_type, }) else: line.tax_key = frozendict({'id': line.id}) @@ -933,6 +934,7 @@ class AccountMoveLine(models.Model): 'tax_tag_ids': [(6, 0, tax['tag_ids'])], 'partner_id': line.move_id.partner_id.id or line.partner_id.id, 'move_id': line.move_id.id, + 'display_type': line.display_type, }): { 'name': tax['name'], 'balance': tax['amount'] / rate, diff --git a/addons/account/tests/test_account_move_line_tax_details.py b/addons/account/tests/test_account_move_line_tax_details.py index 167b54cf2d3..b34eaba3ac5 100644 --- a/addons/account/tests/test_account_move_line_tax_details.py +++ b/addons/account/tests/test_account_move_line_tax_details.py @@ -654,6 +654,47 @@ class TestAccountTaxDetailsReport(AccountTestInvoicingCommon): ) self.assertTotalAmounts(invoice, tax_details) + def test_round_per_line_update(self): + self.env.company.tax_calculation_rounding_method = 'round_per_line' + + tax_8 = self.env['account.tax'].create({ + 'name': "tax_8", + 'amount_type': 'percent', + 'amount': 8.0, + }) + + invoice = self.env['account.move'].create({ + 'move_type': 'out_invoice', + 'partner_id': self.partner_a.id, + 'invoice_date': '2019-01-01', + 'invoice_cash_rounding_id': self.cash_rounding_b.id, + 'invoice_line_ids': [ + Command.create({ + 'name': 'line1', + 'account_id': self.company_data['default_account_revenue'].id, + 'price_unit': 45.45, + 'tax_ids': [Command.set(tax_8.ids)], + }) + ] + }) + invoice.invoice_line_ids.write({"price_unit": 4545}) + + base_lines, tax_lines = self._dispatch_move_lines(invoice) + + tax_details = self._get_tax_details() + self.assertTaxDetailsValues( + tax_details, + [ + { + 'base_line_id': base_lines[0].id, + 'tax_line_id': tax_lines[0].id, + 'base_amount': -4545.0, + 'tax_amount': -363.6, + }, + ], + ) + self.assertTotalAmounts(invoice, tax_details) + def test_partitioning_lines_by_moves(self): tax_20_affect = self.env['account.tax'].create({ 'name': "tax_20_affect", diff --git a/addons/account/tests/test_early_payment_discount.py b/addons/account/tests/test_early_payment_discount.py index 00fe85a6826..4b2720fca1f 100644 --- a/addons/account/tests/test_early_payment_discount.py +++ b/addons/account/tests/test_early_payment_discount.py @@ -87,7 +87,8 @@ class TestAccountEarlyPaymentDiscount(AccountTestInvoicingCommon): {'display_type': 'epd', 'balance': -100.0}, {'display_type': 'epd', 'balance': 100.0}, {'display_type': 'product', 'balance': -1000.0}, - {'display_type': 'tax', 'balance': -135.0}, + {'display_type': 'tax', 'balance': -150}, + {'display_type': 'tax', 'balance': 15.0}, {'display_type': 'tax', 'balance': -0.05}, {'display_type': 'payment_term', 'balance': 1135.05}, ], {