From ba1706eca125a6d6cfafce3d4d338caba7b165ad Mon Sep 17 00:00:00 2001 From: "Ali Alfie (alal)" Date: Mon, 15 Jan 2024 16:17:53 +0100 Subject: [PATCH] [ADD] l10n_es_edi_facturae_invoice_period: invoice periods for EDI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch module to add missing fields to the factura-e xml. task-3673113 closes odoo/odoo#149362 Signed-off-by: William André (wan) --- .../__init__.py | 1 + .../__manifest__.py | 16 ++ .../i18n/es.po | 41 ++++ .../l10n_es_edi_facturae_invoice_period.pot | 40 +++ .../models/__init__.py | 1 + .../models/account_move.py | 19 ++ .../tests/__init__.py | 1 + .../data/expected_invoice_period_document.xml | 231 ++++++++++++++++++ .../tests/test_edi_xml.py | 29 +++ .../views/account_move_views.xml | 19 ++ 10 files changed, 398 insertions(+) create mode 100644 addons/l10n_es_edi_facturae_invoice_period/__init__.py create mode 100644 addons/l10n_es_edi_facturae_invoice_period/__manifest__.py create mode 100644 addons/l10n_es_edi_facturae_invoice_period/i18n/es.po create mode 100644 addons/l10n_es_edi_facturae_invoice_period/i18n/l10n_es_edi_facturae_invoice_period.pot create mode 100644 addons/l10n_es_edi_facturae_invoice_period/models/__init__.py create mode 100644 addons/l10n_es_edi_facturae_invoice_period/models/account_move.py create mode 100644 addons/l10n_es_edi_facturae_invoice_period/tests/__init__.py create mode 100644 addons/l10n_es_edi_facturae_invoice_period/tests/data/expected_invoice_period_document.xml create mode 100644 addons/l10n_es_edi_facturae_invoice_period/tests/test_edi_xml.py create mode 100644 addons/l10n_es_edi_facturae_invoice_period/views/account_move_views.xml diff --git a/addons/l10n_es_edi_facturae_invoice_period/__init__.py b/addons/l10n_es_edi_facturae_invoice_period/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/addons/l10n_es_edi_facturae_invoice_period/__manifest__.py b/addons/l10n_es_edi_facturae_invoice_period/__manifest__.py new file mode 100644 index 00000000000..44c26eab4c4 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/__manifest__.py @@ -0,0 +1,16 @@ +{ + 'name': 'Spain - Facturae EDI - Invoice Period', + 'version': '1.0', + 'description': """ + Patch module to add the missing Invoice Period in the Facturae EDI. + """, + 'license': 'LGPL-3', + 'category': 'Accounting/Localizations/EDI', + 'depends': [ + 'l10n_es_edi_facturae', + ], + 'data': [ + 'views/account_move_views.xml', + ], + 'auto_install': True, +} diff --git a/addons/l10n_es_edi_facturae_invoice_period/i18n/es.po b/addons/l10n_es_edi_facturae_invoice_period/i18n/es.po new file mode 100644 index 00000000000..b0bfb61f654 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/i18n/es.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_edi_facturae_invoice_period +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-01-23 13:35+0000\n" +"PO-Revision-Date: 2024-01-23 13:35+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_es_edi_facturae_invoice_period +#: model_terms:ir.ui.view,arch_db:l10n_es_edi_facturae_invoice_period.view_move_form +msgid "Factura-e" +msgstr "" + +#. module: l10n_es_edi_facturae_invoice_period +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_bank_statement_line__l10n_es_invoicing_period_end_date +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_move__l10n_es_invoicing_period_end_date +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_payment__l10n_es_invoicing_period_end_date +msgid "Invoice Period End Date" +msgstr "Fecha final del periodo de facturación" + +#. module: l10n_es_edi_facturae_invoice_period +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_bank_statement_line__l10n_es_invoicing_period_start_date +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_move__l10n_es_invoicing_period_start_date +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_payment__l10n_es_invoicing_period_start_date +msgid "Invoice Period Start Date" +msgstr "Fecha de inicio del periodo de facturación" + +#. module: l10n_es_edi_facturae_invoice_period +#: model:ir.model,name:l10n_es_edi_facturae_invoice_period.model_account_move +msgid "Journal Entry" +msgstr "Asiento contable" diff --git a/addons/l10n_es_edi_facturae_invoice_period/i18n/l10n_es_edi_facturae_invoice_period.pot b/addons/l10n_es_edi_facturae_invoice_period/i18n/l10n_es_edi_facturae_invoice_period.pot new file mode 100644 index 00000000000..7a448e0d634 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/i18n/l10n_es_edi_facturae_invoice_period.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_edi_facturae_invoice_period +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-01-23 13:35+0000\n" +"PO-Revision-Date: 2024-01-23 13:35+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_es_edi_facturae_invoice_period +#: model_terms:ir.ui.view,arch_db:l10n_es_edi_facturae_invoice_period.view_move_form +msgid "Factura-e" +msgstr "" + +#. module: l10n_es_edi_facturae_invoice_period +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_bank_statement_line__l10n_es_invoicing_period_end_date +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_move__l10n_es_invoicing_period_end_date +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_payment__l10n_es_invoicing_period_end_date +msgid "Invoice Period End Date" +msgstr "" + +#. module: l10n_es_edi_facturae_invoice_period +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_bank_statement_line__l10n_es_invoicing_period_start_date +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_move__l10n_es_invoicing_period_start_date +#: model:ir.model.fields,field_description:l10n_es_edi_facturae_invoice_period.field_account_payment__l10n_es_invoicing_period_start_date +msgid "Invoice Period Start Date" +msgstr "" + +#. module: l10n_es_edi_facturae_invoice_period +#: model:ir.model,name:l10n_es_edi_facturae_invoice_period.model_account_move +msgid "Journal Entry" +msgstr "" diff --git a/addons/l10n_es_edi_facturae_invoice_period/models/__init__.py b/addons/l10n_es_edi_facturae_invoice_period/models/__init__.py new file mode 100644 index 00000000000..9c0a4213854 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/addons/l10n_es_edi_facturae_invoice_period/models/account_move.py b/addons/l10n_es_edi_facturae_invoice_period/models/account_move.py new file mode 100644 index 00000000000..af7e00b0172 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/models/account_move.py @@ -0,0 +1,19 @@ +from odoo import fields, models + +class AccountMove(models.Model): + _inherit = 'account.move' + + l10n_es_invoicing_period_start_date = fields.Date(string="Invoice Period Start Date") + l10n_es_invoicing_period_end_date = fields.Date(string="Invoice Period End Date") + + def _l10n_es_edi_facturae_export_facturae(self): + # EXTENDS l10n_es_edi_facturae + template_values, signature_values = super()._l10n_es_edi_facturae_export_facturae() + + invoicing_period = { + 'StartDate': self.l10n_es_invoicing_period_start_date, + 'EndDate': self.l10n_es_invoicing_period_end_date, + } if self.l10n_es_invoicing_period_start_date and self.l10n_es_invoicing_period_end_date else None + + template_values['Invoices'][0]['InvoiceIssueData']['InvoicingPeriod'] = invoicing_period + return template_values, signature_values diff --git a/addons/l10n_es_edi_facturae_invoice_period/tests/__init__.py b/addons/l10n_es_edi_facturae_invoice_period/tests/__init__.py new file mode 100644 index 00000000000..d3a8ed6ec33 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/tests/__init__.py @@ -0,0 +1 @@ +from . import test_edi_xml diff --git a/addons/l10n_es_edi_facturae_invoice_period/tests/data/expected_invoice_period_document.xml b/addons/l10n_es_edi_facturae_invoice_period/tests/data/expected_invoice_period_document.xml new file mode 100644 index 00000000000..4903dfa9e39 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/tests/data/expected_invoice_period_document.xml @@ -0,0 +1,231 @@ + + + 3.2.2 + I + EM + + INV/2023/00001 + 1 + + 121.00 + + + 121.00 + + + 121.00 + + EUR + + + + + + J + R + ES59962470K + + + company_1_data + company_1_data + +
C. de Embajadores, 68-116
+ 12345 + Madrid + Madrid + ESP +
+
+
+ + + F + U + BE0477472701 + + + UNKNOWN + UNKNOWN + +
Rue de Bruxelles, 15000
+ 5000 Namur + Belgium + BEL +
+
+
+
+ + + + INV/2023/00001 + FC + OO + + + 2023-01-01 + + 2023-01-01 + 2023-01-31 + + EUR + EUR + en + + + + 01 + 21.000 + + 100.00 + + + 21.00 + + + + + 100.00 + 100.00 + 21.00 + 0.00 + 121.00 + 121.00 + 121.00 + + + + product_a + 1.0 + 01 + 100.00 + 100.00 + 100.00 + + + 01 + 21.000 + + 100.00 + + + 21.00 + + + + + + + + + + + + + + + + + JAhNpeZX8by/1HgAFallJjZiJkBrvucV3HsBlYCWKPQ= + + + + e1hl1wSxZ4LGKE3NEGEplc9jRwRgQwDqyRoWo7Jx1+Q= + + + + ey6Kj6XATgVzIh/1+h55n4LfhiBAA4FRGmcNwSs+j6A= + + + jDUl6pOeuRuehXDleAz53WCGSoJhXdOHsPzOGDEYWWKI2d3Q4CW26A+4UE7vimrm5cAFt8h6vcks +/q2l/P3eXnn0iLO/SyHN33nUSv1T1UgZWW97BQBh7viol3q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cAaWAYAMCL4KhvISclysD+5juDLpGCLHPtKxBXTQIDAQABo0MwQTAfBgNVHSMEGDAW +gBTmxEG4Ub7b5wRXqWea94Vs1hB13zAJBgNVHRMEAjAAMBMGA1UdEQQMMAqCCG9kb28uY29tMA0G +CSqGSIb3DQEBCwUAA4IBAQAFLvTlSELTVWRfIlGthoFOmkv8MrwJuo8y7qTmvsFXeA2hZtsPdNxx +iwAGPobiUO0GCEPUFKZ7NksQa7DAKGXfb5RSwfujDfEMAhgi00+wF1VIKeKqnGt4idzCr+2NtiQY +e9oK+Ee7o82llnNFwbWvRKx55lhHW3bwN6Tl31qUYbxacJyA9z5sQpe2zImWMVsm4g7OAjzg3Cn2 +0TFu+0XekB892n7DYh4gHiMWaMOVYmi/aEWLSqxMlbiHQr75FmPftozFvTxW26jU3ALhq+yXPVa4 +lg4r/h6HH5TbtSjYzTSJ4MvMyrECgIQYf0zsS4D6K/GvCZbu7LKHRwuC0fis + + + + + tGUbyNJrA3yyOC01gIMR1A1rWIHCHD+afLCLCddBDZwC4Q034yFBuMqQFNWaxxLc9s+wFbNZqu5D +7rynN3qXvWJj40VZxygoV/09y71IhaspuAZ0rdzYsqjDmTJiPSrEl6iydF2eq6sJ4J0ItCUFc2e8 +8B25wz7esslAN249C20oQj5ZiGifR4P0CRQSmDy0SPYZGxTurVwtq6IsYbOqEw8/Wqx6ApOltper +FX88DZCdbY59ZedqQrGQh2Z5Au7h/8nhmdbpz7Ixw2zocxVigR0ClNDpKKxvolX1virQpICkfWcA +aWAYAMCL4KhvISclysD+5juDLpGCLHPtKxBXTQ== + + AQAB + + + + + + + + + 2023-01-01T00:00:00 + + + + + FHf2lN+5FALNa7JXV2+pByL92/dr8LeCVhpItYic5oA= + + + C=BE, CN=runbot.odoo.com, L=Ramillies, O=Odoo, OU=R&D, ST=Wallonnia + 548631688851000697209704649636588277530075594025 + + + + + + + http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf + Política de firma electrónica para facturación electrónica con formato Facturae + + + + a/vDoueJq9zxWGCFwdsXdlXtkFSEek4XVtmlQCEDaE8= + + + + http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf + + + + + + + + + + urn:oid:1.2.840.10003.5.109.10 + + + text/xml + + + + + + + +
diff --git a/addons/l10n_es_edi_facturae_invoice_period/tests/test_edi_xml.py b/addons/l10n_es_edi_facturae_invoice_period/tests/test_edi_xml.py new file mode 100644 index 00000000000..fe3d2a2bac7 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/tests/test_edi_xml.py @@ -0,0 +1,29 @@ +import lxml +from freezegun.api import freeze_time + +from odoo.tests import tagged +from odoo.tools import file_open + +from odoo.addons.l10n_es_edi_facturae.tests.test_edi_xml import TestEdiFacturaeXmls + + +@tagged('post_install_l10n', 'post_install', '-at_install') +class TestEdiFacturaeInvoicePeriodXmls(TestEdiFacturaeXmls): + + @freeze_time('2023-01-01') + def test_generate_with_invoice_period(self): + invoice = self.create_invoice( + partner_id=self.partner_a.id, + move_type='out_invoice', + invoice_line_ids=[{'price_unit': 100.0, 'tax_ids': [self.tax.id]}], + l10n_es_invoicing_period_start_date='2023-01-01', + l10n_es_invoicing_period_end_date='2023-01-31', + ) + invoice.action_post() + generated_file, errors = invoice._l10n_es_edi_facturae_render_facturae() + self.assertFalse(errors) + self.assertTrue(generated_file) + + with file_open('l10n_es_edi_facturae_invoice_period/tests/data/expected_invoice_period_document.xml', 'rt') as f: + expected_xml = lxml.etree.fromstring(f.read().encode()) + self.assertXmlTreeEqual(lxml.etree.fromstring(generated_file), expected_xml) diff --git a/addons/l10n_es_edi_facturae_invoice_period/views/account_move_views.xml b/addons/l10n_es_edi_facturae_invoice_period/views/account_move_views.xml new file mode 100644 index 00000000000..b7de617e0d2 --- /dev/null +++ b/addons/l10n_es_edi_facturae_invoice_period/views/account_move_views.xml @@ -0,0 +1,19 @@ + + + + + account.move.form + account.move + + + + + + + + + + + +