From 7fbb337e31f0e7e1a6714d8dbf73facb00854dda Mon Sep 17 00:00:00 2001 From: Thomas Beckers <tbs@odoo.com> Date: Fri, 16 Sep 2022 12:21:11 +0000 Subject: [PATCH] [FIX] Ignore CABA moves when checking 'Reversed' state on invoice To check if the state 'Reversed' should be set on an invoice. We checked that the full reconciliation moves only contain the invoice, the reverse move and the potential exchange move. However, it's possible to have also some CABA moves for the invoice and credit note when the tax used have a CABA transition account which is reconcilable (eg. tax "IVA(16%) VENTAS"). So if this append the status 'Paid' will be set instead. Now, we take into account those CABA moves and the status will be set to 'Reversed' accordingly. opw-2976667 closes odoo/odoo#100380 Signed-off-by: Olivier Colson (oco) <oco@odoo.com> --- addons/account/models/account_move.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index b381d379b979..c46a4550afe4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1484,10 +1484,12 @@ class AccountMove(models.Model): if new_pmt_state == 'paid' and move.move_type in ('in_invoice', 'out_invoice', 'entry'): reverse_type = move.move_type == 'in_invoice' and 'in_refund' or move.move_type == 'out_invoice' and 'out_refund' or 'entry' reverse_moves = self.env['account.move'].search([('reversed_entry_id', '=', move.id), ('state', '=', 'posted'), ('move_type', '=', reverse_type)]) + caba_moves = self.env['account.move'].search([('tax_cash_basis_move_id', 'in', move.ids + reverse_moves.ids), ('state', '=', 'posted')]) # We only set 'reversed' state in cas of 1 to 1 full reconciliation with a reverse entry; otherwise, we use the regular 'paid' state + # We ignore potentials cash basis moves reconciled because the transition account of the tax is reconcilable reverse_moves_full_recs = reverse_moves.mapped('line_ids.full_reconcile_id') - if reverse_moves_full_recs.mapped('reconciled_line_ids.move_id').filtered(lambda x: x not in (reverse_moves + reverse_moves_full_recs.mapped('exchange_move_id'))) == move: + if reverse_moves_full_recs.mapped('reconciled_line_ids.move_id').filtered(lambda x: x not in (caba_moves + reverse_moves + reverse_moves_full_recs.mapped('exchange_move_id'))) == move: new_pmt_state = 'reversed' move.payment_state = new_pmt_state -- GitLab