Skip to content

Commit

Permalink
[REV] account: commit d22cd54
Browse files Browse the repository at this point in the history
d22cd54 introduced the fact that when doing a full refund of an invoice, the same account was used as on the original invoice, instead of the one on the tax refund repartition lines, though the tags were still the refund ones. This is wrong.

Also, it restored an inconsistent data setup in a test, while the current version was actually correct.

X-original-commit: 031f017
Part-of: odoo#84727
  • Loading branch information
jbw-odoo committed Feb 16, 2022
1 parent f6030ae commit df37d3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,11 @@ def compute_tax_repartition_lines_mapping(move_vals):
'credit': credit,
})

if not is_refund:
if not is_refund or self.tax_cash_basis_origin_move_id:
# We don't map tax repartition for non-refund operations, nor for cash basis entries.
# Indeed, cancelling a cash basis entry usually happens when unreconciling and invoice,
# in which case we always want the reverse entry to totally cancel the original one, keeping the same accounts,
# tags and repartition lines
continue

# ==== Map tax repartition lines ====
Expand All @@ -2718,9 +2722,6 @@ def compute_tax_repartition_lines_mapping(move_vals):
refund_repartition_line = tax_repartition_lines_mapping[invoice_repartition_line]

# Find the right account.
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:
Expand Down
1 change: 1 addition & 0 deletions addons/account/tests/test_account_move_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,7 @@ def test_reconcile_cash_basis_exchange_difference_transfer_account_check_entries
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',
Expand Down

0 comments on commit df37d3e

Please sign in to comment.