From 3775ba785edc59fa5a29b1912dc34790f4ec67d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Wed, 27 Jan 2021 11:35:09 +0100 Subject: [PATCH 01/18] Import customer invoices facturae --- .../__manifest__.py | 5 +- .../tests/files/facturae_customer_01.xml | 251 ++++++++++++++++++ .../tests/test_import_facturae.py | 59 ++++ .../wizard/account_invoice_import.py | 20 +- oca_dependencies.txt | 2 +- 5 files changed, 328 insertions(+), 9 deletions(-) create mode 100644 account_invoice_import_facturae/tests/files/facturae_customer_01.xml diff --git a/account_invoice_import_facturae/__manifest__.py b/account_invoice_import_facturae/__manifest__.py index 89e9266233d..9a94bafa73b 100644 --- a/account_invoice_import_facturae/__manifest__.py +++ b/account_invoice_import_facturae/__manifest__.py @@ -3,10 +3,11 @@ { 'name': 'Account Invoice Import Facturae', - 'version': '12.0.1.0.0', + 'version': '12.0.2.0.0', 'category': 'Accounting & Finance', 'license': 'AGPL-3', - 'summary': 'Import supplier invoices/refunds in facturae format', + 'summary': 'Import supplier invoices/refunds and ' + 'customer invoices in facturae format', 'author': 'Creu Blanca, Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/l10n-spain', 'depends': [ diff --git a/account_invoice_import_facturae/tests/files/facturae_customer_01.xml b/account_invoice_import_facturae/tests/files/facturae_customer_01.xml new file mode 100644 index 00000000000..07adb6b21ba --- /dev/null +++ b/account_invoice_import_facturae/tests/files/facturae_customer_01.xml @@ -0,0 +1,251 @@ + + + + + 3.2 + I + EM + + INV/2021/000555020639Q + 1 + + 121.00 + 121.00 + + + 121.00 + 121.00 + + + 121.00 + 121.00 + + EUR + + + + + + + + J + E + 55020639Q + + + + + YourCompany + YourCompany + + + + +
1725 Slough Ave.
+ 18540Scranton + Pennsylvania + USA +
+ + +1 555 123 8069 + + http://www.example.com + info@yourcompany.example.com + YourCompany + + + + + +
+ + +
+ + + + + J + E + 03421018K + + + + + Azure Interior + Azure Interior + + + + +
3404 Edgewood Road
+ 72401Jonesboro + Arkansas + USA +
+ + (870)-931-0505 + + http://www.azure-interior.com + azure.Interior24@example.com + Azure Interior + + + + + +
+ + +
+
+ + + + + + + + + + + + + INV/2021/0005 + + FC + OO + + + + 2021-04-09 + + + + EUR + + EUR + en + + + + + + 01 + 21.00 + + 100.00 + 100.00 + + + 21.00 + 21.00 + + + + + + + + + + + 100.00 + + + + + 100.00 + 21.00 + 0.00 + 121.00 + + + + + 121.00 + + + 121.00 + + + + + + + + + + + + + + + + + + + + + + test + 1.0 + + 100.000000 + + 100.000000 + + + 100.000000 + + + + + 01 + 21.00 + + 100.00 + 100.00 + + + 21.00 + 21.00 + + + + + + + + + + + + + + + 2021-05-31 + 121.00 + 04 + + + + + FR7642424242424242424242424 + + + PSSTFRPPXXX + + + + + + + + + + + + + +
diff --git a/account_invoice_import_facturae/tests/test_import_facturae.py b/account_invoice_import_facturae/tests/test_import_facturae.py index 28f71eb616a..341d385ba16 100644 --- a/account_invoice_import_facturae/tests/test_import_facturae.py +++ b/account_invoice_import_facturae/tests/test_import_facturae.py @@ -16,6 +16,12 @@ 'country': 'DEU', 'vat': 'DE111111125', 'product_code': 'RX'}, } +configurations_customer = { + 'facturae_customer_01.xml': { + 'country': 'ESP', 'vat': 'ESA86025558', 'product_code': 'VNAC' + } +} + class TestImportFacturae(TransactionCase): def setUp(self): @@ -69,3 +75,56 @@ def check_config(self, config, vals): def test_import(self): for config in configurations: self.check_config(config, configurations[config]) + + +class TestImportCustomerFacturae(TransactionCase): + def setUp(self): + super().setUp() + self.config = self.env['account.invoice.import.config'].create({ + 'name': 'Facturae', + 'invoice_line_method': 'nline_auto_product', + 'type': 'customer' + }) + self.tax = self.env['account.tax'].create({ + 'name': 'Test tax', + 'type_tax_use': 'purchase', + 'amount_type': 'percent', + 'amount': 21., + 'description': 'TEST TAX', + }) + self.product = self.env['product.product'].create({ + 'name': 'Product', + 'supplier_taxes_id': [(4, self.tax.id)], + }) + + def check_config(self, config, vals): + country = self.env['res.country'].search([ + ('code', '=', vals['country'])]) + country.ensure_one() + partner = self.env['res.partner'].create({ + 'name': 'Partner', + 'invoice_import_ids': [(4, self.config.id)], + 'country_id': country.id, + 'vat': vals['vat'], + 'customer': True, + }) + self.product.default_code = vals['product_code'] + filename = config + f = file_open( + 'account_invoice_import_facturae/tests/files/' + filename, 'rb') + xml_file = f.read() + wiz = self.env['account.invoice.import'].with_context( + customer=True + ).create({ + 'invoice_file': base64.b64encode(xml_file), + 'invoice_filename': filename, + }) + f.close() + action = wiz.import_invoice() + invoice = self.env['account.invoice'].browse(action['res_id']) + self.assertTrue(invoice) + self.assertEqual(invoice.partner_id, partner) + + def test_import(self): + for config in configurations_customer: + self.check_config(config, configurations_customer[config]) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index 22c27d25639..d421dcf25aa 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -65,18 +65,24 @@ def parse_facturae_invoice(self, xml_root, xsd_file): modality = xml_root.find('FileHeader/Modality').text if modality == 'L': raise ValidationError(_('System does not allow lots')) - supplier_dict = self.facturae_parse_partner(xml_root, xml_root.find( - 'Parties/SellerParty' - )) + if 'customer' in self.env.context: + partner_dict = self.facturae_parse_partner(xml_root, xml_root.find( + 'Parties/BuyerParty' + )) + inv_type = 'out_invoice' + else: + partner_dict = self.facturae_parse_partner(xml_root, xml_root.find( + 'Parties/SellerParty' + )) + inv_type = 'in_invoice' invoice = xml_root.find('Invoices/Invoice') inv_number_xpath = invoice.find('InvoiceHeader/InvoiceNumber') - inv_type = 'in_invoice' inv_class = invoice.find('InvoiceHeader/InvoiceClass') if inv_class is not None and inv_class.text not in ['OO', 'OC']: inv_type = 'in_refund' date_dt = datetime.strptime( - invoice.find('InvoiceIssueData/IssueDate').text, '%Y-%M-%d') + invoice.find('InvoiceIssueData/IssueDate').text, '%Y-%m-%d') date_start = False date_end = False amount_total = float(invoice.find('InvoiceTotals/InvoiceTotal').text) @@ -90,7 +96,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): attachments = {} res = { 'type': inv_type, - 'partner': supplier_dict, + 'partner': partner_dict, 'invoice_number': inv_number_xpath.text, 'date': date_dt.date(), 'date_due': False, @@ -99,6 +105,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): 'currency': {'iso': invoice.find( 'InvoiceIssueData/InvoiceCurrencyCode').text}, 'amount_total': amount_total, + 'check_total': amount_total, 'amount_untaxed': amount_untaxed, 'iban': False, 'bic': False, @@ -118,6 +125,7 @@ def facturae_parse_partner(self, xml_root, partner): country = self.env['res.country'].search([('code_alpha3', '=', iso)]) country.ensure_one() vat = partner.find('TaxIdentification/TaxIdentificationNumber').text + vat = vat.replace("-", "") if not vat.startswith(country.code): vat = country.code + vat return { diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 13511f7d9dd..02089f02ffb 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -13,4 +13,4 @@ account-invoicing intrastat-extrastat stock-logistics-workflow delivery-carrier -edi +edi https://github.com/coopdevs/edi 12.0-account_invoice_import_out_invoices From 6f613a8ac9bb7387c74c7e6744091cd7e7668269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Fri, 9 Apr 2021 15:58:11 +0200 Subject: [PATCH 02/18] Add country id in customer test vat --- .../tests/files/facturae_customer_01.xml | 2 +- account_invoice_import_facturae/tests/test_import_facturae.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/account_invoice_import_facturae/tests/files/facturae_customer_01.xml b/account_invoice_import_facturae/tests/files/facturae_customer_01.xml index 07adb6b21ba..77897bfeaa4 100644 --- a/account_invoice_import_facturae/tests/files/facturae_customer_01.xml +++ b/account_invoice_import_facturae/tests/files/facturae_customer_01.xml @@ -67,7 +67,7 @@ J E - 03421018K + ES03421018K diff --git a/account_invoice_import_facturae/tests/test_import_facturae.py b/account_invoice_import_facturae/tests/test_import_facturae.py index 341d385ba16..4a844b28a77 100644 --- a/account_invoice_import_facturae/tests/test_import_facturae.py +++ b/account_invoice_import_facturae/tests/test_import_facturae.py @@ -18,7 +18,7 @@ configurations_customer = { 'facturae_customer_01.xml': { - 'country': 'ESP', 'vat': 'ESA86025558', 'product_code': 'VNAC' + 'country': 'ESP', 'vat': 'ES03421018K', 'product_code': 'VNAC' } } From 17504ae4dc6fc14c36d7bd08953ce9c5ecb32d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Fri, 9 Apr 2021 16:07:19 +0200 Subject: [PATCH 03/18] Set country customer invoice test partner --- .../tests/files/facturae_customer_01.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_invoice_import_facturae/tests/files/facturae_customer_01.xml b/account_invoice_import_facturae/tests/files/facturae_customer_01.xml index 77897bfeaa4..9e2b4addd0b 100644 --- a/account_invoice_import_facturae/tests/files/facturae_customer_01.xml +++ b/account_invoice_import_facturae/tests/files/facturae_customer_01.xml @@ -81,7 +81,7 @@
3404 Edgewood Road
72401Jonesboro Arkansas - USA + ESP (870)-931-0505 From 877f37b9dda9db2d1ccf47df187662011b418b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Wed, 14 Apr 2021 12:01:35 +0200 Subject: [PATCH 04/18] Use test product and ESP country code --- .../tests/files/facturae_customer_01.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/account_invoice_import_facturae/tests/files/facturae_customer_01.xml b/account_invoice_import_facturae/tests/files/facturae_customer_01.xml index 9e2b4addd0b..17ceb9e0e3d 100644 --- a/account_invoice_import_facturae/tests/files/facturae_customer_01.xml +++ b/account_invoice_import_facturae/tests/files/facturae_customer_01.xml @@ -44,7 +44,7 @@
1725 Slough Ave.
18540Scranton Pennsylvania - USA + ESP +1 555 123 8069 @@ -214,6 +214,7 @@ + VNAC From 19d7f162de262d4de922ff36e13eb255b9a0ade1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Mon, 2 Aug 2021 15:54:18 +0200 Subject: [PATCH 05/18] Add schemas for CNE Extensions --- l10n_es_facturae/data/CNEExtension.xsd | 84 ++++++++++++++++++++++++++ l10n_es_facturae/data/Facturaev3_2.xsd | 20 +++--- 2 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 l10n_es_facturae/data/CNEExtension.xsd diff --git a/l10n_es_facturae/data/CNEExtension.xsd b/l10n_es_facturae/data/CNEExtension.xsd new file mode 100644 index 00000000000..430c29c7cf9 --- /dev/null +++ b/l10n_es_facturae/data/CNEExtension.xsd @@ -0,0 +1,84 @@ + + + + + + Elemento ORIGEN de la Extensión de las líneas. + + + + + + + + + + + + + + Línea de factura (DISTRIBUIDORA). + + + + + + + + + + + Línea de factura para sujeto de liquidación + + + + + + + + + + + + Tipo de Código de Liquidación. + + + + + + + + + + Tipo de Código de Instalación a efectos de Liquidación. + + + + + + + + + + MM/AAAA + + + + + + + + + + 'F' + 'AAMM' + Tipo Liq ('1') + secuenciador de 10dígitos. + + + + + + + + + \ No newline at end of file diff --git a/l10n_es_facturae/data/Facturaev3_2.xsd b/l10n_es_facturae/data/Facturaev3_2.xsd index 6eea2e657cd..4dae24e0b52 100644 --- a/l10n_es_facturae/data/Facturaev3_2.xsd +++ b/l10n_es_facturae/data/Facturaev3_2.xsd @@ -1,6 +1,7 @@ - - + + + Element ORIGIN of Facturae Invoices File. @@ -692,12 +693,13 @@ Código de artículo. - - - New structured definitions can be incorporated when they are of collective interest of the issuers and recipients, and have not already been defined in the invoice schema. - Extensiones. Podrán incorporarse nuevas definiciones estructuradas cuando sean de interés conjunto para emisores y receptores, y no estén ya definidas en el esquema de la factura. - - + + + + + + + @@ -3418,4 +3420,4 @@ - \ No newline at end of file + From fa76737a684a2d8ef5edd423a83531bb6df68a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Mon, 2 Aug 2021 16:21:52 +0200 Subject: [PATCH 06/18] Allow dates without zero padding in month --- l10n_es_facturae/data/CNEExtension.xsd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/l10n_es_facturae/data/CNEExtension.xsd b/l10n_es_facturae/data/CNEExtension.xsd index 430c29c7cf9..8edfe08ab23 100644 --- a/l10n_es_facturae/data/CNEExtension.xsd +++ b/l10n_es_facturae/data/CNEExtension.xsd @@ -66,8 +66,9 @@ - - + + + @@ -81,4 +82,4 @@ - \ No newline at end of file + From 86cf31cfae3ed57d4f87fdcc6b407fb63a096c75 Mon Sep 17 00:00:00 2001 From: susu105 Date: Mon, 4 Apr 2022 18:08:09 +0200 Subject: [PATCH 07/18] added invoice_series_code --- .../wizard/account_invoice_import.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index d421dcf25aa..53c8d9239ba 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -78,6 +78,8 @@ def parse_facturae_invoice(self, xml_root, xsd_file): invoice = xml_root.find('Invoices/Invoice') inv_number_xpath = invoice.find('InvoiceHeader/InvoiceNumber') + inv_series_code_xpath = invoice.find('InvoiceHeader/InvoiceSeriesCode') + inv_class = invoice.find('InvoiceHeader/InvoiceClass') if inv_class is not None and inv_class.text not in ['OO', 'OC']: inv_type = 'in_refund' @@ -98,6 +100,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): 'type': inv_type, 'partner': partner_dict, 'invoice_number': inv_number_xpath.text, + 'invoice_series_code': inv_series_code_xpath.text, 'date': date_dt.date(), 'date_due': False, 'date_start': date_start, From 3d0dabc6423ab56243de10424a51bc50b25a9c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Tue, 7 Feb 2023 15:40:39 +0100 Subject: [PATCH 08/18] Set customer IBAN from XML in invoice --- account_invoice_import_facturae/__manifest__.py | 1 + .../wizard/account_invoice_import.py | 4 +++- setup/account_invoice_import_facturae/setup.py | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/account_invoice_import_facturae/__manifest__.py b/account_invoice_import_facturae/__manifest__.py index 9a94bafa73b..7d1d9273be7 100644 --- a/account_invoice_import_facturae/__manifest__.py +++ b/account_invoice_import_facturae/__manifest__.py @@ -20,6 +20,7 @@ 'external_dependencies': { 'python': [ 'xmlsig', + 'schwifty', ] }, 'images': ['images/sshot-wizard1.png'], diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index 53c8d9239ba..813b1063d8d 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -11,6 +11,7 @@ from odoo.tools.translate import _ from odoo.exceptions import ValidationError logger = logging.getLogger(__name__) +from schwifty import IBAN try: import xmlsig @@ -96,6 +97,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): invoice.find('Items').findall('InvoiceLine') ] attachments = {} + acc_number = invoice.find('PaymentDetails/Installment/AccountToBeDebited/AccountNumber').text res = { 'type': inv_type, 'partner': partner_dict, @@ -110,7 +112,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): 'amount_total': amount_total, 'check_total': amount_total, 'amount_untaxed': amount_untaxed, - 'iban': False, + 'iban': str(IBAN.generate('ES',acc_number[0:4],acc_number[8:20],acc_number[4:8])), 'bic': False, 'lines': res_lines, 'attachments': attachments, diff --git a/setup/account_invoice_import_facturae/setup.py b/setup/account_invoice_import_facturae/setup.py index 28c57bb6403..dd7e8cad4db 100644 --- a/setup/account_invoice_import_facturae/setup.py +++ b/setup/account_invoice_import_facturae/setup.py @@ -2,5 +2,12 @@ setuptools.setup( setup_requires=['setuptools-odoo'], - odoo_addon=True, + odoo_addon={ + "external_dependencies_override": { + "python": { + "schwifty": "schwifty==2023.2.0", + "xmlsig": "0.1.4", + }, + + }, ) From 7b1a8c4d6041a60b90c5e8360759043685bb18b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Tue, 7 Feb 2023 15:41:15 +0100 Subject: [PATCH 09/18] Disable validation --- .../wizard/account_invoice_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index 813b1063d8d..3df73823200 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -57,7 +57,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): xsd_file, subdir="addons/l10n_es_facturae/data" ))) - facturae_schema.assertValid(xml_root) + # facturae_schema.assertValid(xml_root) sign = xml_root.find( 'ds:Signature', namespaces={'ds': xmlsig.constants.DSigNs} ) From 1e24e0c320c540bb27f99fe6cb57179227706533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Fri, 10 Feb 2023 13:18:18 +0100 Subject: [PATCH 10/18] Fix typo --- setup/account_invoice_import_facturae/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/account_invoice_import_facturae/setup.py b/setup/account_invoice_import_facturae/setup.py index dd7e8cad4db..985b384328d 100644 --- a/setup/account_invoice_import_facturae/setup.py +++ b/setup/account_invoice_import_facturae/setup.py @@ -8,6 +8,6 @@ "schwifty": "schwifty==2023.2.0", "xmlsig": "0.1.4", }, - + }, }, ) From 78665e213d402fdbe48a696c6fc7658397ff9376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Fri, 10 Feb 2023 13:18:57 +0100 Subject: [PATCH 11/18] Resolved bug that prevents invoice parsing when there is not acc_number --- .../wizard/account_invoice_import.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index 3df73823200..66e79b1709e 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -97,7 +97,8 @@ def parse_facturae_invoice(self, xml_root, xsd_file): invoice.find('Items').findall('InvoiceLine') ] attachments = {} - acc_number = invoice.find('PaymentDetails/Installment/AccountToBeDebited/AccountNumber').text + acc_number = invoice.find('PaymentDetails/Installment/AccountToBeDebited/AccountNumber') + acc_number = acc_number and acc_number.value res = { 'type': inv_type, 'partner': partner_dict, @@ -112,7 +113,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): 'amount_total': amount_total, 'check_total': amount_total, 'amount_untaxed': amount_untaxed, - 'iban': str(IBAN.generate('ES',acc_number[0:4],acc_number[8:20],acc_number[4:8])), + 'iban': acc_number and str(IBAN.generate('ES',acc_number[0:4],acc_number[8:20],acc_number[4:8])), 'bic': False, 'lines': res_lines, 'attachments': attachments, From 934c7511e34eac86655fd19c234ff85ecdaa163d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Fri, 10 Feb 2023 13:32:12 +0100 Subject: [PATCH 12/18] Fix typo in setup.py --- setup/account_invoice_import_facturae/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/account_invoice_import_facturae/setup.py b/setup/account_invoice_import_facturae/setup.py index 985b384328d..80d6b71c0f7 100644 --- a/setup/account_invoice_import_facturae/setup.py +++ b/setup/account_invoice_import_facturae/setup.py @@ -6,7 +6,7 @@ "external_dependencies_override": { "python": { "schwifty": "schwifty==2023.2.0", - "xmlsig": "0.1.4", + "xmlsig": "xmlsig==0.1.4", }, }, }, From f44300f1489da2aacf64e761b1d36b3e2555e779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Mon, 20 Feb 2023 14:57:43 +0100 Subject: [PATCH 13/18] Change ToBeDebited -> ToBeCredited --- .../wizard/account_invoice_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index 66e79b1709e..c9d417c5946 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -97,7 +97,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): invoice.find('Items').findall('InvoiceLine') ] attachments = {} - acc_number = invoice.find('PaymentDetails/Installment/AccountToBeDebited/AccountNumber') + acc_number = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber') acc_number = acc_number and acc_number.value res = { 'type': inv_type, From cdacb1b4d1d706521c504c5fcbf060e1c3c434fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Mon, 20 Feb 2023 17:04:38 +0100 Subject: [PATCH 14/18] Set text value directly --- .../wizard/account_invoice_import.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index c9d417c5946..3715e9d19f7 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -97,8 +97,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): invoice.find('Items').findall('InvoiceLine') ] attachments = {} - acc_number = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber') - acc_number = acc_number and acc_number.value + acc_number = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber').text res = { 'type': inv_type, 'partner': partner_dict, From 2ffafd5b02f619f0fbc971c86aea14816844df78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Mon, 20 Feb 2023 17:14:38 +0100 Subject: [PATCH 15/18] limit acc_number set to customer invoices --- .../wizard/account_invoice_import.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index 3715e9d19f7..566e69158b4 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -97,7 +97,10 @@ def parse_facturae_invoice(self, xml_root, xsd_file): invoice.find('Items').findall('InvoiceLine') ] attachments = {} - acc_number = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber').text + if 'customer' in self.env.context: + acc_number = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber').text + else: + acc_number = False res = { 'type': inv_type, 'partner': partner_dict, From 416de0f6edd7d71bf925d01848eb403ad0df4673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Thu, 2 Mar 2023 12:31:00 +0100 Subject: [PATCH 16/18] Fix multi-tag iban for customer invoices --- .../wizard/account_invoice_import.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index 566e69158b4..deaca55bca6 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -98,7 +98,9 @@ def parse_facturae_invoice(self, xml_root, xsd_file): ] attachments = {} if 'customer' in self.env.context: - acc_number = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber').text + account_to_be_credited = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber') + account_to_be_debited = invoice.find('PaymentDetails/Installment/AccountToBeDebited/AccountNumber') + acc_number = (account_to_be_debited and account_to_be_debited.text or account_to_be_credited and account_to_be_credited.text) else: acc_number = False res = { From 917213ee76c97c596576b9b884cc817c1d219d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Palomar=20Rodr=C3=ADguez?= Date: Mon, 20 Mar 2023 19:53:57 +0100 Subject: [PATCH 17/18] Fix Element evaluation Warning when try to cast an Element Tree in a Boolean. Use `is not None` --- .../wizard/account_invoice_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index deaca55bca6..3bf73e54246 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -100,7 +100,7 @@ def parse_facturae_invoice(self, xml_root, xsd_file): if 'customer' in self.env.context: account_to_be_credited = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber') account_to_be_debited = invoice.find('PaymentDetails/Installment/AccountToBeDebited/AccountNumber') - acc_number = (account_to_be_debited and account_to_be_debited.text or account_to_be_credited and account_to_be_credited.text) + acc_number = (account_to_be_debited is not None and account_to_be_debited.text or account_to_be_credited is not None and account_to_be_credited.text) else: acc_number = False res = { From 4cb23ac3808394d352f9e41514b40de4db8e5912 Mon Sep 17 00:00:00 2001 From: Daniel Palomar Date: Thu, 23 Mar 2023 16:24:17 +0100 Subject: [PATCH 18/18] use acc_number in every import: credited and debited --- .../wizard/account_invoice_import.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/account_invoice_import_facturae/wizard/account_invoice_import.py b/account_invoice_import_facturae/wizard/account_invoice_import.py index 3bf73e54246..eaed6069e35 100644 --- a/account_invoice_import_facturae/wizard/account_invoice_import.py +++ b/account_invoice_import_facturae/wizard/account_invoice_import.py @@ -97,12 +97,18 @@ def parse_facturae_invoice(self, xml_root, xsd_file): invoice.find('Items').findall('InvoiceLine') ] attachments = {} - if 'customer' in self.env.context: - account_to_be_credited = invoice.find('PaymentDetails/Installment/AccountToBeCredited/AccountNumber') - account_to_be_debited = invoice.find('PaymentDetails/Installment/AccountToBeDebited/AccountNumber') - acc_number = (account_to_be_debited is not None and account_to_be_debited.text or account_to_be_credited is not None and account_to_be_credited.text) - else: - acc_number = False + account_to_be_credited = invoice.find( + "PaymentDetails/Installment/AccountToBeCredited/AccountNumber" + ) + account_to_be_debited = invoice.find( + "PaymentDetails/Installment/AccountToBeDebited/AccountNumber" + ) + acc_number = ( + account_to_be_debited is not None + and account_to_be_debited.text + or account_to_be_credited is not None + and account_to_be_credited.text + ) res = { 'type': inv_type, 'partner': partner_dict,