[FIX] account_edi_ubl_cii: handle the date format while import invoices
When the user tries to import the invoice file with space on both sides of the date value the error will be generated. Steps to reproduce: 1. Install the `account_edi_ubl_cii` module. 2. Generate one `factur-x.xml` file or import this file https://drive.google.com/file/d/1RCqLT37j2g6LPkauf75LpOzZt64XHd_L/view?usp=drive_link 3. Go to the invoice app and click the `upload` button. 4. Select the `factur-x.xml` file and an error will be generated at the backend and nothing to be imported. This commit fixes the issue by removing the extra spaces in the date value, if user gives the spaces in the invoice file. see- https://github.com/odoo/odoo/blob/a0ea6302a574624604cad7d0903711b30a4802a6/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py#L315 sentry-4331059603 closes odoo/odoo#132670 X-original-commit: 1f32b5ec0e1a670a879d983c45a3108f73341435 Signed-off-by: Laurent Smet (las) <las@odoo.com>
This commit is contained in:
@@ -311,7 +311,7 @@ class AccountEdiXmlCII(models.AbstractModel):
|
||||
|
||||
invoice_date_node = tree.find('./{*}ExchangedDocument/{*}IssueDateTime/{*}DateTimeString')
|
||||
if invoice_date_node is not None and invoice_date_node.text:
|
||||
date_str = invoice_date_node.text
|
||||
date_str = invoice_date_node.text.strip()
|
||||
date_obj = datetime.strptime(date_str, DEFAULT_FACTURX_DATE_FORMAT)
|
||||
invoice.invoice_date = date_obj.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
@@ -319,7 +319,7 @@ class AccountEdiXmlCII(models.AbstractModel):
|
||||
|
||||
invoice_date_due_node = tree.find('.//{*}SpecifiedTradePaymentTerms/{*}DueDateDateTime/{*}DateTimeString')
|
||||
if invoice_date_due_node is not None and invoice_date_due_node.text:
|
||||
date_str = invoice_date_due_node.text
|
||||
date_str = invoice_date_due_node.text.strip()
|
||||
date_obj = datetime.strptime(date_str, DEFAULT_FACTURX_DATE_FORMAT)
|
||||
invoice.invoice_date_due = date_obj.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user