From 23f2b70a2368a78f1cd0ab52f538849a2bf9bd56 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Fri, 1 Apr 2022 13:50:26 +0000 Subject: [PATCH] [FIX] account: Fix traceack when registering a 0 amount payment => Create an invoice in foreign currency => Register a payment of 0 using the currency of the company and select "Keep open" A traceback is raised closes odoo/odoo#87886 X-original-commit: 14894623029c24230dea92ccef950cff914e1704 Signed-off-by: Olivier Colson Signed-off-by: Laurent Smet --- addons/account/wizard/account_payment_register.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/account/wizard/account_payment_register.py b/addons/account/wizard/account_payment_register.py index dc5b98d599d..1c1d9bd8cb2 100644 --- a/addons/account/wizard/account_payment_register.py +++ b/addons/account/wizard/account_payment_register.py @@ -598,10 +598,11 @@ class AccountPaymentRegister(models.TransientModel): debit_lines = (liquidity_lines + counterpart_lines).filtered('debit') credit_lines = (liquidity_lines + counterpart_lines).filtered('credit') - payment.move_id.write({'line_ids': [ - (1, debit_lines[0].id, {'debit': debit_lines[0].debit + delta_balance}), - (1, credit_lines[0].id, {'credit': credit_lines[0].credit + delta_balance}), - ]}) + if debit_lines and credit_lines: + payment.move_id.write({'line_ids': [ + (1, debit_lines[0].id, {'debit': debit_lines[0].debit + delta_balance}), + (1, credit_lines[0].id, {'credit': credit_lines[0].credit + delta_balance}), + ]}) return payments def _post_payments(self, to_process, edit_mode=False):