[FIX] account: Fix traceback when refunding invoice with tax on_payment

- Create an invoice using a tax exigible on_payment.
- Refund the invoice with 'Full refund'.
=> Traceback: The lines are already reconciled.

Explanation:
Odoo tried to reconcile all lines having a reconcile account, including the one set on taxes.
- The first reconciliation is made on the receivable account triggering the cash basis entries that will be reconcile with the tax account.
- The second reconciliation fails because the account has been reconciled to the cash basis entries.

closes odoo/odoo#55594

X-original-commit: 01f2a4c3d95b4ea762ef34ae56ee717a9614cb1a
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
Laurent Smet
2020-08-06 21:28:00 +00:00
parent 7742f0b42b
commit 71aa83beed
+3 -2
View File
@@ -2232,7 +2232,8 @@ class AccountMove(models.Model):
.filtered(lambda account: account.reconcile or account.internal_type == 'liquidity')
for account in accounts:
(move.line_ids + reverse_move.line_ids)\
.filtered(lambda line: line.account_id == account and line.balance)\
.filtered(lambda line: line.account_id == account and not line.reconciled)\
.with_context(move_reverse_cancel=cancel)\
.reconcile()
return reverse_moves
@@ -4371,7 +4372,7 @@ class AccountMoveLine(models.Model):
# ==== Create entries for cash basis taxes ====
is_cash_basis_needed = account.user_type_id.type in ('receivable', 'payable')
if is_cash_basis_needed:
if is_cash_basis_needed and not self._context.get('move_reverse_cancel'):
tax_cash_basis_moves = partials._create_tax_cash_basis_moves()
results['tax_cash_basis_moves'] = tax_cash_basis_moves