From 4851cbc094c50c28c9f959a51efb68ef8f327c72 Mon Sep 17 00:00:00 2001 From: Hoang Tran Date: Thu, 6 Jan 2022 10:03:03 +0000 Subject: [PATCH] [FIX] sale: only reconcile with posted payment if linked transactions While posting an invoice, if the transactions linked with the invoice are failed due to valid reason from the payment acquirer, forcing reconciliation on transactions' payment will raise an error because such payment isn't posted. closes odoo/odoo#82895 X-original-commit: 52937b441432b56994dda857d8cdee06b8128872 Signed-off-by: Laurent Smet --- addons/sale/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/account_move.py b/addons/sale/models/account_move.py index c854192372a..2a5348fedd3 100644 --- a/addons/sale/models/account_move.py +++ b/addons/sale/models/account_move.py @@ -92,7 +92,7 @@ class AccountMove(models.Model): posted = super()._post(soft) for invoice in posted.filtered(lambda move: move.is_invoice()): - payments = invoice.mapped('transaction_ids.payment_id') + payments = invoice.mapped('transaction_ids.payment_id').filtered(lambda x: x.state == 'posted') move_lines = payments.line_ids.filtered(lambda line: line.account_internal_type in ('receivable', 'payable') and not line.reconciled) for line in move_lines: invoice.js_assign_outstanding_line(line.id)