From 1f32b5ec0e1a670a879d983c45a3108f73341435 Mon Sep 17 00:00:00 2001 From: Archana Vaghasiya <arva@odoo.com> Date: Mon, 24 Jul 2023 11:27:41 +0000 Subject: [PATCH] [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#129374 Signed-off-by: Laurent Smet (las) <las@odoo.com> --- .../account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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 e21139c0dc7d..859035854fba 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 @@ -308,7 +308,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_form.invoice_date = date_obj.strftime(DEFAULT_SERVER_DATE_FORMAT) @@ -316,7 +316,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_form.invoice_date_due = date_obj.strftime(DEFAULT_SERVER_DATE_FORMAT) -- GitLab