From 6e1f24100d91acc5b60ccda6c7ef46a802731878 Mon Sep 17 00:00:00 2001 From: Mahamadasif Ansari Date: Wed, 10 May 2023 11:05:31 +0000 Subject: [PATCH] [FIX] account_edi_ubl_cii: prevent ZeroDivisionError log error A float division by zero error is generated on the log, and nothing is imported from the file when the user uploads an XML file like https://drive.google.com/file/d/1_eZYfqMk2kLtPsEjv-13DRHnmoXkWYeE. This is because here in LineID 1, there is a value billed quantity is 0.0, a charge amount is 0.0, and a total amount is 100.0. This is wrong; the total amount is always 0.0 when the billed quantity is 0.0 (billed quantity * charge amount). This commit solves the above issue by dividing a price subtotal by one when the billed quantity is zero. sentry-4157357719 closes odoo/odoo#122142 X-original-commit: 3a6e84d6733145f38184c473de4a1aa41464b1fa Signed-off-by: Quentin De Paoli Signed-off-by: Ansari Mahamadasif (maan) --- addons/account_edi_ubl_cii/models/account_edi_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_edi_ubl_cii/models/account_edi_common.py b/addons/account_edi_ubl_cii/models/account_edi_common.py index 30a007296ea..6c809c63472 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_common.py +++ b/addons/account_edi_ubl_cii/models/account_edi_common.py @@ -623,7 +623,7 @@ class AccountEdiCommon(models.AbstractModel): # for instance, when filling a down payment as an invoice line. The equation in the docstring is not # respected, and the result will not be correct, so we just follow the simple rule below: if net_price_unit == 0 and price_subtotal != net_price_unit * (billed_qty / basis_qty) - allow_charge_amount: - price_unit = price_subtotal / billed_qty + price_unit = price_subtotal / (billed_qty or 1) return { 'quantity': quantity,