From bfc83df736596a32f6009ad673194db20f18dec8 Mon Sep 17 00:00:00 2001 From: Quentin <quvb@odoo.com> Date: Mon, 11 Sep 2023 12:44:25 +0200 Subject: [PATCH] [FIX] account_edi_ubl_cii: handle 0 basis_qty and None attachement_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When parsed, if the attachment has a basis quantity of zero, it creates an error, because it is used in a division. The condition that checks whether is computed should be done only if this variable is none. The code does not handle if `attachement_name.text` is None, which can be caused by an orphan ID tag (e.i. "<cbc:ID />") , in the xml of the pdf. opw-3470969 closes odoo/odoo#135270 Signed-off-by: William André (wan) <wan@odoo.com> --- addons/account_edi_ubl_cii/models/account_edi_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3958eb81cb8e..cd4c6c18bca2 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_common.py +++ b/addons/account_edi_ubl_cii/models/account_edi_common.py @@ -314,7 +314,7 @@ class AccountEdiCommon(models.AbstractModel): # Normalize the name of the file : some e-fff emitters put the full path of the file # (Windows or Linux style) and/or the name of the xml instead of the pdf. # Get only the filename with a pdf extension. - name = attachment_name.text.split('\\')[-1].split('/')[-1].split('.')[0] + '.pdf' + name = (attachment_name.text or 'invoice').split('\\')[-1].split('/')[-1].split('.')[0] + '.pdf' attachment = self.env['ir.attachment'].create({ 'name': name, 'res_id': invoice.id, @@ -515,7 +515,7 @@ class AccountEdiCommon(models.AbstractModel): for xpath in xpath_dict['basis_qty']: basis_quantity_node = tree.find(xpath) if basis_quantity_node is not None: - basis_qty = float(basis_quantity_node.text) + basis_qty = float(basis_quantity_node.text) or 1 # gross_price_unit (optional) gross_price_unit = None -- GitLab