From e76d6dc88c7e87841f091614d9eca97229931d3d Mon Sep 17 00:00:00 2001 From: aliya Date: Mon, 16 Jan 2023 13:50:35 +0000 Subject: [PATCH] [FIX] account_edi_ubl_cii: fix invoice import Sometimes the invoice import fails, because `payment_terms_node.text` can be None and we're trying to concatenate it with a string. This commit makes sure that `payment_terms_node.text` is there first. task-3132980 closes odoo/odoo#110430 X-original-commit: 3a3c83b90ed1bdedc2bb6aca59928225e3fdb55d Signed-off-by: John Laterre (jol) Signed-off-by: Aliya Tastemirova (alta) --- .../models/account_edi_xml_cii_facturx.py | 8 ++++---- .../account_edi_ubl_cii/models/account_edi_xml_ubl_20.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py index 90c489ec2ce..835c1083afc 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py @@ -250,11 +250,11 @@ class AccountEdiXmlCII(models.AbstractModel): narration = "" note_node = tree.find('./{*}ExchangedDocument/{*}IncludedNote/{*}Content') - if note_node is not None: + if note_node is not None and note_node.text: narration += note_node.text + "\n" payment_terms_node = tree.find('.//{*}SpecifiedTradePaymentTerms/{*}Description') - if payment_terms_node is not None: + if payment_terms_node is not None and payment_terms_node.text: narration += payment_terms_node.text + "\n" invoice.narration = narration @@ -268,7 +268,7 @@ class AccountEdiXmlCII(models.AbstractModel): # ==== invoice_date ==== invoice_date_node = tree.find('./{*}ExchangedDocument/{*}IssueDateTime/{*}DateTimeString') - if invoice_date_node is not None: + if invoice_date_node is not None and invoice_date_node.text: date_str = invoice_date_node.text date_obj = datetime.strptime(date_str, DEFAULT_FACTURX_DATE_FORMAT) invoice.invoice_date = date_obj.strftime(DEFAULT_SERVER_DATE_FORMAT) @@ -276,7 +276,7 @@ class AccountEdiXmlCII(models.AbstractModel): # ==== invoice_date_due ==== invoice_date_due_node = tree.find('.//{*}SpecifiedTradePaymentTerms/{*}DueDateDateTime/{*}DateTimeString') - if invoice_date_due_node is not None: + if invoice_date_due_node is not None and invoice_date_due_node.text: date_str = invoice_date_due_node.text date_obj = datetime.strptime(date_str, DEFAULT_FACTURX_DATE_FORMAT) invoice.invoice_date_due = date_obj.strftime(DEFAULT_SERVER_DATE_FORMAT) diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py index 08074c35ceb..c9b9cd3f679 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py @@ -501,7 +501,7 @@ class AccountEdiXmlUBL20(models.AbstractModel): narration += note_node.text + "\n" payment_terms_node = tree.find('./{*}PaymentTerms/{*}Note') # e.g. 'Payment within 10 days, 2% discount' - if payment_terms_node is not None: + if payment_terms_node is not None and payment_terms_node.text: narration += payment_terms_node.text + "\n" invoice.narration = narration @@ -515,14 +515,14 @@ class AccountEdiXmlUBL20(models.AbstractModel): # ==== invoice_date ==== invoice_date_node = tree.find('./{*}IssueDate') - if invoice_date_node is not None: + if invoice_date_node is not None and invoice_date_node.text: invoice.invoice_date = invoice_date_node.text # ==== invoice_date_due ==== for xpath in ('./{*}DueDate', './/{*}PaymentDueDate'): invoice_date_due_node = tree.find(xpath) - if invoice_date_due_node is not None: + if invoice_date_due_node is not None and invoice_date_due_node.text: invoice.invoice_date_due = invoice_date_due_node.text break