[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) <jol@odoo.com> Signed-off-by: Aliya Tastemirova (alta) <alta@odoo.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user