From 2dc1612ddc27f9650ad610d1d3966eee13d2ebd7 Mon Sep 17 00:00:00 2001 From: "Paolo Gatti (pgi)" Date: Fri, 18 Aug 2023 16:41:34 +0200 Subject: [PATCH] [IMP] l10n_it_edi_pa: Split Payment New module is created (`l10n_it_edi_pa`) to add fields that are required to handle Split Payment, and it will be merged in master. - `l10n_it_origin_document_type` - `l10n_it_origin_document_date` - `l10n_it_origin_document_name` - `l10n_it_cup` - `l10n_it_cig` These fields are required to track money used that comes from funding to the Public Administration business for purchases, be it ordinary or project based spending. They also need to be exported in XML during the EDI phase, in different XML nodes depending on the `l10n_it_origin_document_type` field ref: https://fex-app.com/FatturaElettronica/FatturaElettronicaBody/DatiGenerali/DatiOrdineAcquisto Task link: https://www.odoo.com/web#id=2823645&model=project.task task-2823645 X-original-commit: e07fb2503f28af1f23ef74efec6741f9623ce401 Part-of: odoo/odoo#134348 --- .../l10n_it_edi/data/invoice_it_template.xml | 6 +- .../tests/export_xmls/split_payment.xml | 96 +++++++++++++ addons/l10n_it_edi_pa/__init__.py | 3 + addons/l10n_it_edi_pa/__manifest__.py | 28 ++++ addons/l10n_it_edi_pa/i18n/it.po | 130 ++++++++++++++++++ addons/l10n_it_edi_pa/i18n/l10n_it_edi_pa.pot | 125 +++++++++++++++++ addons/l10n_it_edi_pa/models/__init__.py | 4 + .../models/account_edi_format.py | 17 +++ addons/l10n_it_edi_pa/models/account_move.py | 46 +++++++ addons/l10n_it_edi_pa/tests/__init__.py | 3 + addons/l10n_it_edi_pa/tests/test_edi_pa.py | 75 ++++++++++ .../views/account_move_view.xml | 23 ++++ .../l10n_it_edi_pa/views/report_invoice.xml | 13 ++ 13 files changed, 566 insertions(+), 3 deletions(-) create mode 100644 addons/l10n_it_edi/tests/export_xmls/split_payment.xml create mode 100644 addons/l10n_it_edi_pa/__init__.py create mode 100644 addons/l10n_it_edi_pa/__manifest__.py create mode 100644 addons/l10n_it_edi_pa/i18n/it.po create mode 100644 addons/l10n_it_edi_pa/i18n/l10n_it_edi_pa.pot create mode 100644 addons/l10n_it_edi_pa/models/__init__.py create mode 100644 addons/l10n_it_edi_pa/models/account_edi_format.py create mode 100644 addons/l10n_it_edi_pa/models/account_move.py create mode 100644 addons/l10n_it_edi_pa/tests/__init__.py create mode 100644 addons/l10n_it_edi_pa/tests/test_edi_pa.py create mode 100644 addons/l10n_it_edi_pa/views/account_move_view.xml create mode 100644 addons/l10n_it_edi_pa/views/report_invoice.xml diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml index c5578bd7791..e67d3a8e591 100644 --- a/addons/l10n_it_edi/data/invoice_it_template.xml +++ b/addons/l10n_it_edi/data/invoice_it_template.xml @@ -140,11 +140,11 @@ - - + + - + diff --git a/addons/l10n_it_edi/tests/export_xmls/split_payment.xml b/addons/l10n_it_edi/tests/export_xmls/split_payment.xml new file mode 100644 index 00000000000..62dcc234381 --- /dev/null +++ b/addons/l10n_it_edi/tests/export_xmls/split_payment.xml @@ -0,0 +1,96 @@ + + + + + + IT + 01234560157 + + FPA12 + 123456 + + 0266766700 + test@test.it + + + + + + IT + 01234560157 + + 01234560157 + + company_2_data + + RF01 + + + 1234 Test Street + 12345 + Prova + IT + + + + + + IT + 06655971007 + + 06655971007 + + pa partner + + + + Via Test PA + 32121 + PA Town + IT + + + + + + + TD01 + EUR + 2022-03-24 + INV/2022/00001 + 976.49 + + + INV/2022/0001 + 2022-03-23 + 0123456789 + 0987654321 + + + + + 1 + standard_line + 1.00 + 800.400000 + 800.40 + 22.00 + + + 22.00 + 800.40 + 176.09 + S + + + + TP02 + + MP05 + 2022-03-24 + 800.40 + ___ignore___ + + + + diff --git a/addons/l10n_it_edi_pa/__init__.py b/addons/l10n_it_edi_pa/__init__.py new file mode 100644 index 00000000000..d6210b1285d --- /dev/null +++ b/addons/l10n_it_edi_pa/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/addons/l10n_it_edi_pa/__manifest__.py b/addons/l10n_it_edi_pa/__manifest__.py new file mode 100644 index 00000000000..344ba13a1d3 --- /dev/null +++ b/addons/l10n_it_edi_pa/__manifest__.py @@ -0,0 +1,28 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +{ + 'name': 'Italy - E-invoicing (PA)', + 'version': '0.1', + 'depends': [ + 'l10n_it_edi' + ], + 'auto_install': ['l10n_it_edi'], + 'author': 'Odoo', + 'description': """ +Public Administration partners flow handling for the E-invoice implementation for Italy. + + Several more fields are required for invoicing Public Administration businesses. + The Origin Document is to be exported in the XML when invoicing the Public Administration, + It can be a Contract, an Agreement, a Purchase Order, a Linked Invoice or a Down Payment, + it will need the CIG and CUP fields which are mandatory. + They both serve the purpose to trace public funds being invested on purchases. + CIG is the Tender Unique Identifier, CUP identifies the Public Project of Investment. + """, + 'category': 'Accounting/Localizations/EDI', + 'website': 'https://www.odoo.com/documentation/16.0/applications/finance/accounting/fiscal_localizations/localizations/italy.html', + 'data': [ + 'views/account_move_view.xml', + 'views/report_invoice.xml', + ], + 'license': 'LGPL-3', +} diff --git a/addons/l10n_it_edi_pa/i18n/it.po b/addons/l10n_it_edi_pa/i18n/it.po new file mode 100644 index 00000000000..bcee4514c52 --- /dev/null +++ b/addons/l10n_it_edi_pa/i18n/it.po @@ -0,0 +1,130 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_edi_pa +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-08-19 00:02+0000\n" +"PO-Revision-Date: 2023-08-19 00:02+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_it_edi_pa +#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__agreement +msgid "Agreement" +msgstr "Convenzione" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cig +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_cig +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_cig +msgid "CIG" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cup +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_cup +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_cup +msgid "CUP" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__contract +msgid "Contract" +msgstr "Contratto" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_partner_pa_index +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_partner_pa_index +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_partner_pa_index +msgid "Destination Code" +msgstr "Codice Destinatario" + +#. module: l10n_it_edi_pa +#: model:ir.model,name:l10n_it_edi_pa.model_account_edi_format +msgid "EDI format" +msgstr "Formato EDI" + +#. module: l10n_it_edi_pa +#: model:ir.model,name:l10n_it_edi_pa.model_account_move +msgid "Journal Entry" +msgstr "Movimento Contabile" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_partner_pa_index +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_partner_pa_index +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_partner_pa_index +msgid "" +"Must contain the 6-character (or 7) code, present in the PA " +"Index in the information relative to the electronic invoicing service," +" associated with the office which, within the addressee " +"administration, deals with receiving (and processing) the " +"invoice." +msgstr "Deve contenere il codice da 6-7 caratteri presente nell'indice della PA " +"nelle informazioni relative al servizio di Fatturazione Elettronica, " +"associato all'ufficio dell'amministrazione che riceverá (ed elaborerá) la Fattura." + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_date +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_date +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_date +msgid "Origin Document Date" +msgstr "Data Documento Origine" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_name +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_name +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_name +msgid "Origin Document Name" +msgstr "Nome Documento Origine" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_type +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_type +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_type +msgid "Origin Document Type" +msgstr "Tipo Documento Origine" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cup +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_cup +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_cup +msgid "Public Investment Unique Identifier" +msgstr "CUP" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__purchase_order +msgid "Purchase Order" +msgstr "Ordine d'Acquisto" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cig +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_cig +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_cig +msgid "Tender Unique Identifier" +msgstr "CIG" + +#. module: l10n_it_edi_pa +#. odoo-python +#: code:addons/l10n_it_edi_pa/models/account_edi_format.py:0 +#, python-format +msgid "The Origin Document Date cannot be in the future." +msgstr "La Data Documento Origine non può essere nel futuro." + +#. module: l10n_it_edi_pa +#. odoo-python +#: code:addons/l10n_it_edi_pa/models/account_edi_format.py:0 +#, python-format +msgid "" +"This invoice targets the Public Administration, please fill out Origin " +"Document Type field in the Electronic Invoicing tab." +msgstr "" +"Questa fattura ha come cliente la Pubblica Amministrazione, " +"per favore riempi il Tipo Documento Origine nel tab Fatturazione " +"Elettronica" diff --git a/addons/l10n_it_edi_pa/i18n/l10n_it_edi_pa.pot b/addons/l10n_it_edi_pa/i18n/l10n_it_edi_pa.pot new file mode 100644 index 00000000000..6fbdd9307a8 --- /dev/null +++ b/addons/l10n_it_edi_pa/i18n/l10n_it_edi_pa.pot @@ -0,0 +1,125 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_edi_pa +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-08-19 00:02+0000\n" +"PO-Revision-Date: 2023-08-19 00:02+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_it_edi_pa +#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__agreement +msgid "Agreement" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cig +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_cig +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_cig +msgid "CIG" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cup +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_cup +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_cup +msgid "CUP" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__contract +msgid "Contract" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_partner_pa_index +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_partner_pa_index +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_partner_pa_index +msgid "Destination Code" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model,name:l10n_it_edi_pa.model_account_edi_format +msgid "EDI format" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model,name:l10n_it_edi_pa.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_partner_pa_index +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_partner_pa_index +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_partner_pa_index +msgid "" +"Must contain the 6-character (or 7) code, present in the PA " +"Index in the information relative to the electronic invoicing service," +" associated with the office which, within the addressee " +"administration, deals with receiving (and processing) the " +"invoice." +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_date +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_date +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_date +msgid "Origin Document Date" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_name +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_name +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_name +msgid "Origin Document Name" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_type +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_type +#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_type +msgid "Origin Document Type" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cup +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_cup +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_cup +msgid "Public Investment Unique Identifier" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: l10n_it_edi_pa +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cig +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_cig +#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_cig +msgid "Tender Unique Identifier" +msgstr "" + +#. module: l10n_it_edi_pa +#. odoo-python +#: code:addons/l10n_it_edi_pa/models/account_edi_format.py:0 +#, python-format +msgid "The Origin Document Date cannot be in the future." +msgstr "" + +#. module: l10n_it_edi_pa +#. odoo-python +#: code:addons/l10n_it_edi_pa/models/account_edi_format.py:0 +#, python-format +msgid "" +"This invoice targets the Public Administration, please fill out Origin " +"Document Type field in the Electronic Invoicing tab." +msgstr "" diff --git a/addons/l10n_it_edi_pa/models/__init__.py b/addons/l10n_it_edi_pa/models/__init__.py new file mode 100644 index 00000000000..8072ca1f74f --- /dev/null +++ b/addons/l10n_it_edi_pa/models/__init__.py @@ -0,0 +1,4 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import account_move +from . import account_edi_format diff --git a/addons/l10n_it_edi_pa/models/account_edi_format.py b/addons/l10n_it_edi_pa/models/account_edi_format.py new file mode 100644 index 00000000000..9f5b06ebed2 --- /dev/null +++ b/addons/l10n_it_edi_pa/models/account_edi_format.py @@ -0,0 +1,17 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import _, fields, models + + +class AccountEdiFormat(models.Model): + _inherit = 'account.edi.format' + + def _l10n_it_edi_check_ordinary_invoice_configuration(self, invoice): + errors = super()._l10n_it_edi_check_ordinary_invoice_configuration(invoice) + if invoice._is_commercial_partner_pa(): + if not invoice.l10n_it_origin_document_type: + errors.append(_("This invoice targets the Public Administration, please fill out" + " Origin Document Type field in the Electronic Invoicing tab.")) + if invoice.l10n_it_origin_document_date and invoice.l10n_it_origin_document_date > fields.Date.today(): + errors.append(_("The Origin Document Date cannot be in the future.")) + return errors diff --git a/addons/l10n_it_edi_pa/models/account_move.py b/addons/l10n_it_edi_pa/models/account_move.py new file mode 100644 index 00000000000..3c6627e6d40 --- /dev/null +++ b/addons/l10n_it_edi_pa/models/account_move.py @@ -0,0 +1,46 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models + + +class AccountMove(models.Model): + _inherit = 'account.move' + + l10n_it_origin_document_type = fields.Selection( + string="Origin Document Type", + selection=[('purchase_order', 'Purchase Order'), ('contract', 'Contract'), ('agreement', 'Agreement')], + copy=False) + l10n_it_origin_document_name = fields.Char( + string="Origin Document Name", + copy=False) + l10n_it_origin_document_date = fields.Date( + string="Origin Document Date", + copy=False) + l10n_it_cig = fields.Char( + string="CIG", + copy=False, + help="Tender Unique Identifier") + l10n_it_cup = fields.Char( + string="CUP", + copy=False, + help="Public Investment Unique Identifier") + # Technical field for showing the above fields or not + l10n_it_partner_pa = fields.Boolean(compute='_compute_l10n_it_partner_pa') + + @api.depends('commercial_partner_id.l10n_it_pa_index', 'company_id') + def _compute_l10n_it_partner_pa(self): + for move in self: + move.l10n_it_partner_pa = (move.country_code == 'IT' and move.commercial_partner_id.l10n_it_pa_index and + len(move.commercial_partner_id.l10n_it_pa_index) == 6) + + def _prepare_fatturapa_export_values(self): + """Add origin document features.""" + template_values = super()._prepare_fatturapa_export_values() + template_values.update({ + 'origin_document_type': self.l10n_it_origin_document_type, + 'origin_document_name': self.l10n_it_origin_document_name, + 'origin_document_date': self.l10n_it_origin_document_date, + 'cig': self.l10n_it_cig, + 'cup': self.l10n_it_cup, + }) + return template_values diff --git a/addons/l10n_it_edi_pa/tests/__init__.py b/addons/l10n_it_edi_pa/tests/__init__.py new file mode 100644 index 00000000000..5001199ae66 --- /dev/null +++ b/addons/l10n_it_edi_pa/tests/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_edi_pa diff --git a/addons/l10n_it_edi_pa/tests/test_edi_pa.py b/addons/l10n_it_edi_pa/tests/test_edi_pa.py new file mode 100644 index 00000000000..822991b18e1 --- /dev/null +++ b/addons/l10n_it_edi_pa/tests/test_edi_pa.py @@ -0,0 +1,75 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import datetime +from lxml import etree +from odoo.addons.l10n_it_edi.tests.common import TestItEdi +from odoo.exceptions import UserError +from odoo.tests.common import tagged +from odoo import tools +from odoo import Command + +@tagged('post_install_l10n', 'post_install', '-at_install') +class TestItEdiPa(TestItEdi): + + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.Move = cls.env['account.move'].with_company(cls.company) + journal_code = cls.company_data_2['default_journal_sale'].code + cls.split_payment_tax = cls.env['account.tax'].with_company(cls.company).search([('name', '=', '22% SP')]) + cls.split_payment_line_data = { + 'name': 'standard_line', + 'quantity': 1, + 'price_unit': 800.40, + 'tax_ids': [Command.set(cls.split_payment_tax.ids)], + } + + cls.pa_partner_invoice_data = { + 'move_type': 'out_invoice', + 'invoice_date': datetime.date(2022, 3, 24), + 'invoice_date_due': datetime.date(2022, 3, 24), + 'partner_id': cls.italian_partner_b.id, + 'partner_bank_id': cls.test_bank.id, + 'invoice_line_ids': [ + Command.create(cls.split_payment_line_data), + ], + 'l10n_it_origin_document_type': 'purchase_order', + 'l10n_it_origin_document_date': datetime.date(2022, 3, 23), + 'l10n_it_origin_document_name': f"{journal_code}/2022/0001", + 'l10n_it_cup': '0123456789', + 'l10n_it_cig': '0987654321' + } + cls.pa_partner_invoice = cls.Move.create(cls.pa_partner_invoice_data) + cls.pa_partner_invoice_2 = cls.Move.create({ + **cls.pa_partner_invoice_data, + 'l10n_it_origin_document_type': False, + }) + cls.pa_partner_invoice._post() + cls.split_payment_invoice_content = cls._get_test_file_content('split_payment.xml') + + @classmethod + def _get_test_file_content(cls, filename): + """ Get the content of a test file inside this module """ + path = 'l10n_it_edi/tests/export_xmls/' + filename + with tools.file_open(path, mode='rb') as test_file: + return test_file.read() + + def test_send_pa_partner(self): + res = self.edi_format._l10n_it_post_invoices_step_1(self.pa_partner_invoice) + self.assertEqual(res[self.pa_partner_invoice], {'attachment': self.pa_partner_invoice.l10n_it_edi_attachment_id, 'success': True}) + + def test_send_pa_partner_missing_field(self): + with self.assertRaises(UserError): + self.pa_partner_invoice_2._post() + + def test_split_payment(self): + """ ImportoTotaleDocumento must include VAT + ImportoPagamento must be without VAT + EsigibilitaIva of the Split payment tax must be 'S' + The orgin_document fields must appear in the XML. + Use reference validator: https://fex-app.com/servizi/inizia + """ + invoice_etree = self._cleanup_etree(self.edi_format._l10n_it_edi_export_invoice_as_xml(self.pa_partner_invoice)) + expected_etree = etree.fromstring(self.split_payment_invoice_content) + self.assertXmlTreeEqual(invoice_etree, expected_etree) diff --git a/addons/l10n_it_edi_pa/views/account_move_view.xml b/addons/l10n_it_edi_pa/views/account_move_view.xml new file mode 100644 index 00000000000..120e8209763 --- /dev/null +++ b/addons/l10n_it_edi_pa/views/account_move_view.xml @@ -0,0 +1,23 @@ + + + + account.move.form.l10n.it.pa + account.move + 20 + + + + + + + + + + + + + + + + + diff --git a/addons/l10n_it_edi_pa/views/report_invoice.xml b/addons/l10n_it_edi_pa/views/report_invoice.xml new file mode 100644 index 00000000000..abe432ea39e --- /dev/null +++ b/addons/l10n_it_edi_pa/views/report_invoice.xml @@ -0,0 +1,13 @@ + + + +