diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 21113d38fee8ae82691f0f54ddeb1b80e9e8b3b8..483af967944f3002e2911a9a5854aa15613f031d 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2401,15 +2401,18 @@ class AccountMove(models.Model): refund_repartition_line = tax_repartition_lines_mapping[invoice_repartition_line] # Find the right account. - account_id = self.env['account.move.line']._get_default_tax_account(refund_repartition_line).id - if not account_id: - if not invoice_repartition_line.account_id: - # Keep the current account as the current one comes from the base line. - account_id = line_vals['account_id'] - else: - tax = invoice_repartition_line.invoice_tax_id - base_line = self.line_ids.filtered(lambda line: tax in line.tax_ids.flatten_taxes_hierarchy())[0] - account_id = base_line.account_id.id + if cancel: + account_id = line_vals['account_id'] + else: + account_id = self.env['account.move.line']._get_default_tax_account(refund_repartition_line).id + if not account_id: + if not invoice_repartition_line.account_id: + # Keep the current account as the current one comes from the base line. + account_id = line_vals['account_id'] + else: + tax = invoice_repartition_line.invoice_tax_id + base_line = self.line_ids.filtered(lambda line: tax in line.tax_ids.flatten_taxes_hierarchy())[0] + account_id = base_line.account_id.id tags = refund_repartition_line.tag_ids if line_vals.get('tax_ids'): diff --git a/addons/account/tests/test_account_move_reconcile.py b/addons/account/tests/test_account_move_reconcile.py index bb58e3bc700a7f4cfa56e6cc5eae0bb8bbb093f8..2e2d83252cc006737335977c68e8f09e2afae80a 100644 --- a/addons/account/tests/test_account_move_reconcile.py +++ b/addons/account/tests/test_account_move_reconcile.py @@ -2060,7 +2060,6 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon): def test_reconcile_cash_basis_revert(self): ''' Ensure the cash basis journal entry can be reverted. ''' self.cash_basis_transfer_account.reconcile = True - self.cash_basis_tax_a_third_amount.cash_basis_transition_account_id = self.tax_account_1 invoice_move = self.env['account.move'].create({ 'move_type': 'entry',