From 71aa83beedf8914629f13e2423d56dc694cd3515 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Thu, 6 Aug 2020 14:55:40 +0000 Subject: [PATCH] [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 Signed-off-by: Laurent Smet --- addons/account/models/account_move.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index ec931923532..3c7832d16e5 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -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