From f7d4ca469d28e7b0c6428ae056bf0b7fe18f4a69 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Fri, 1 Apr 2022 13:08:11 +0000 Subject: [PATCH] [FIX] account: Fix division by zero on register payment wizard - Create an invoice having a foreign currency - Register a payment of 0.0 using a different currency with a write-off of any account => traceback Task: 2809565 X-original-commit: c86faecc980523fcfa6a3258f4c17bf30b41522c Part-of: odoo/odoo#87886 --- addons/account/wizard/account_payment_register.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/wizard/account_payment_register.py b/addons/account/wizard/account_payment_register.py index 4c76fe37efd..dc5b98d599d 100644 --- a/addons/account/wizard/account_payment_register.py +++ b/addons/account/wizard/account_payment_register.py @@ -573,7 +573,10 @@ class AccountPaymentRegister(models.TransientModel): if payment.currency_id != lines.currency_id: liquidity_lines, counterpart_lines, writeoff_lines = payment._seek_for_lines() source_balance = abs(sum(lines.mapped('amount_residual'))) - payment_rate = liquidity_lines[0].amount_currency / liquidity_lines[0].balance + if liquidity_lines[0].balance: + payment_rate = liquidity_lines[0].amount_currency / liquidity_lines[0].balance + else: + payment_rate = 0.0 source_balance_converted = abs(source_balance) * payment_rate # Translate the balance into the payment currency is order to be able to compare them.