diff --git a/l10n_it_edi_sender_partner/README.rst b/l10n_it_edi_sender_partner/README.rst new file mode 100644 index 000000000000..c8c0d99d8389 --- /dev/null +++ b/l10n_it_edi_sender_partner/README.rst @@ -0,0 +1,94 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================================ +Terzo intermediario per fatturazione elettronica +================================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a0af0a681ac91c7ddd3b994e0c6a1741e1c847fba7f75c69387f0613c9231816 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-italy/tree/19.0/l10n_it_edi_sender_partner + :alt: OCA/l10n-italy +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-italy-19-0/l10n-italy-19-0-l10n_it_edi_sender_partner + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +**English** + +Module for managing the Third Party or Issuing Entity in electronic +invoices. A dedicated field is available in the company record. When +sending, if filled in, the intermediary is included in the XML. When +importing, if the file contains an intermediary, it is linked to the +invoice. + +**Italiano** + +Modulo per la gestione del Terzo Intermediario o Soggetto Emittente +nelle fatture elettroniche. Il campo dedicato è disponibile +nell’anagrafica azienda. In fase di invio, se valorizzato, +l’intermediario viene riportato nell’XML. In fase di importazione, se il +file contiene un intermediario, questo viene collegato alla fattura. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Nextev Srl + +Contributors +------------ + +- Nextev Srl + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/l10n-italy `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_it_edi_sender_partner/__init__.py b/l10n_it_edi_sender_partner/__init__.py new file mode 100644 index 000000000000..83e553ac462c --- /dev/null +++ b/l10n_it_edi_sender_partner/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/l10n_it_edi_sender_partner/__manifest__.py b/l10n_it_edi_sender_partner/__manifest__.py new file mode 100644 index 000000000000..e31b5a26aa8a --- /dev/null +++ b/l10n_it_edi_sender_partner/__manifest__.py @@ -0,0 +1,21 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Terzo intermediario per fatturazione elettronica", + "version": "19.0.1.0.0", + "category": "Localization/Italy", + "summary": "Terzo intermediario o soggetto emittete per fatturazione elettronica", + "author": "Nextev Srl, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-italy", + "license": "AGPL-3", + "depends": [ + "l10n_it_edi_extension", + ], + "data": [ + "views/l10n_it_sender_partner.xml", + "views/l10n_it_view.xml", + "views/account_view.xml", + "data/invoice_it_template.xml", + ], + "installable": True, +} diff --git a/l10n_it_edi_sender_partner/data/invoice_it_template.xml b/l10n_it_edi_sender_partner/data/invoice_it_template.xml new file mode 100644 index 000000000000..0037d63b4eb0 --- /dev/null +++ b/l10n_it_edi_sender_partner/data/invoice_it_template.xml @@ -0,0 +1,16 @@ + + + + diff --git a/l10n_it_edi_sender_partner/i18n/l10n_it_edi_sender_partner.pot b/l10n_it_edi_sender_partner/i18n/l10n_it_edi_sender_partner.pot new file mode 100644 index 000000000000..091c040f2bc0 --- /dev/null +++ b/l10n_it_edi_sender_partner/i18n/l10n_it_edi_sender_partner.pot @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_edi_sender_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \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_sender_partner +#: model:ir.model,name:l10n_it_edi_sender_partner.model_res_company +msgid "Companies" +msgstr "" + +#. module: l10n_it_edi_sender_partner +#: model:ir.model.fields,help:l10n_it_edi_sender_partner.field_res_company__l10n_edi_it_sender_partner +msgid "" +"Data of Third-Party Issuer Intermediary who emits the invoice on behalf of " +"the seller/provider" +msgstr "" + +#. module: l10n_it_edi_sender_partner +#: model:ir.model.fields,field_description:l10n_it_edi_sender_partner.field_account_bank_statement_line__l10n_it_edi_intermediary_id +#: model:ir.model.fields,field_description:l10n_it_edi_sender_partner.field_account_move__l10n_it_edi_intermediary_id +msgid "Intermediary" +msgstr "" + +#. module: l10n_it_edi_sender_partner +#: model:ir.model,name:l10n_it_edi_sender_partner.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: l10n_it_edi_sender_partner +#: model_terms:ir.ui.view,arch_db:l10n_it_edi_sender_partner.account_invoice_it_partner_sender +msgid "TZ" +msgstr "" + +#. module: l10n_it_edi_sender_partner +#: model:ir.model.fields,field_description:l10n_it_edi_sender_partner.field_res_company__l10n_edi_it_sender_partner +msgid "Third Party/Sender" +msgstr "" diff --git a/l10n_it_edi_sender_partner/models/__init__.py b/l10n_it_edi_sender_partner/models/__init__.py new file mode 100644 index 000000000000..a1bedba4a8ef --- /dev/null +++ b/l10n_it_edi_sender_partner/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_move +from . import res_company diff --git a/l10n_it_edi_sender_partner/models/account_move.py b/l10n_it_edi_sender_partner/models/account_move.py new file mode 100644 index 000000000000..94080d0abfa5 --- /dev/null +++ b/l10n_it_edi_sender_partner/models/account_move.py @@ -0,0 +1,29 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + +from odoo.addons.l10n_it_edi.models.account_move import get_text + + +class AccountMove(models.Model): + _inherit = "account.move" + + l10n_it_edi_intermediary_id = fields.Many2one("res.partner", string="Intermediary") + + def _l10n_it_edi_import_invoice(self, invoice, data, is_new): + res = super()._l10n_it_edi_import_invoice(invoice, data, is_new) + Partner = self.env["res.partner"] + tree = data["xml_tree"] + intermediary = tree.xpath("//TerzoIntermediarioOSoggettoEmittente") + if not intermediary: + return res + intermediary = intermediary[0] + paese = get_text(intermediary, ".//IdPaese") + codice = get_text(intermediary, ".//IdCodice") + if not codice: + return res + vat = (paese or "") + codice + intermediary_id = Partner.search([("vat", "=", vat)], limit=1) + if intermediary_id: + invoice.l10n_it_edi_intermediary_id = intermediary_id + return res diff --git a/l10n_it_edi_sender_partner/models/res_company.py b/l10n_it_edi_sender_partner/models/res_company.py new file mode 100644 index 000000000000..52626e3f05bc --- /dev/null +++ b/l10n_it_edi_sender_partner/models/res_company.py @@ -0,0 +1,14 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + l10n_edi_it_sender_partner = fields.Many2one( + "res.partner", + string="Third Party/Sender", + help="Data of Third-Party Issuer Intermediary who emits the " + "invoice on behalf of the seller/provider", + ) diff --git a/l10n_it_edi_sender_partner/pyproject.toml b/l10n_it_edi_sender_partner/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/l10n_it_edi_sender_partner/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_it_edi_sender_partner/readme/CONTRIBUTORS.md b/l10n_it_edi_sender_partner/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..a2dfccc30687 --- /dev/null +++ b/l10n_it_edi_sender_partner/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Nextev Srl \<\> + diff --git a/l10n_it_edi_sender_partner/readme/DESCRIPTION.md b/l10n_it_edi_sender_partner/readme/DESCRIPTION.md new file mode 100644 index 000000000000..33a01548325a --- /dev/null +++ b/l10n_it_edi_sender_partner/readme/DESCRIPTION.md @@ -0,0 +1,19 @@ +**English** + +Module for managing the Third Party or Issuing Entity +in electronic invoices. +A dedicated field is available in the company record. +When sending, if filled in, the intermediary is included +in the XML. +When importing, if the file contains an intermediary, +it is linked to the invoice. + +**Italiano** + +Modulo per la gestione del Terzo Intermediario o Soggetto +Emittente nelle fatture elettroniche. +Il campo dedicato è disponibile nell’anagrafica azienda. +In fase di invio, se valorizzato, l’intermediario viene riportato +nell’XML. +In fase di importazione, se il file contiene un intermediario, +questo viene collegato alla fattura. \ No newline at end of file diff --git a/l10n_it_edi_sender_partner/static/description/icon.png b/l10n_it_edi_sender_partner/static/description/icon.png new file mode 100644 index 000000000000..1dcc49c24f36 Binary files /dev/null and b/l10n_it_edi_sender_partner/static/description/icon.png differ diff --git a/l10n_it_edi_sender_partner/static/description/index.html b/l10n_it_edi_sender_partner/static/description/index.html new file mode 100644 index 000000000000..50c61099f981 --- /dev/null +++ b/l10n_it_edi_sender_partner/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Terzo intermediario per fatturazione elettronica

+ +

Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runboat

+

English

+

Module for managing the Third Party or Issuing Entity in electronic +invoices. A dedicated field is available in the company record. When +sending, if filled in, the intermediary is included in the XML. When +importing, if the file contains an intermediary, it is linked to the +invoice.

+

Italiano

+

Modulo per la gestione del Terzo Intermediario o Soggetto Emittente +nelle fatture elettroniche. Il campo dedicato è disponibile +nell’anagrafica azienda. In fase di invio, se valorizzato, +l’intermediario viene riportato nell’XML. In fase di importazione, se il +file contiene un intermediario, questo viene collegato alla fattura.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Nextev Srl
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/l10n-italy project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/l10n_it_edi_sender_partner/tests/__init__.py b/l10n_it_edi_sender_partner/tests/__init__.py new file mode 100644 index 000000000000..e7845c0d4c22 --- /dev/null +++ b/l10n_it_edi_sender_partner/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_import_xml +from . import test_export_xml diff --git a/l10n_it_edi_sender_partner/tests/import_xmls/IT01234567888_FPR01_02.xml b/l10n_it_edi_sender_partner/tests/import_xmls/IT01234567888_FPR01_02.xml new file mode 100644 index 000000000000..3a980b5df06f --- /dev/null +++ b/l10n_it_edi_sender_partner/tests/import_xmls/IT01234567888_FPR01_02.xml @@ -0,0 +1,156 @@ + + + + + IT + 01234560157 + + 00001 + FPR12 + ABC1234 + + + + + + IT + 00313371213 + + 93026890017 + + SOCIETA' ALPHA SRL + + RF19 + + + VIALE ROMA 543 + 07100 + SASSARI + SS + IT + + + + + 01234560157 + + DITTA BETA + + + + VIA TORINO 38-B + 00145 + ROMA + RM + IT + + + + + + IT + 12345670017 + + 12345670017 + + INTERMEDIARIO SRL + + + + TZ + + + + + TD01 + EUR + 2014-12-18 + 01234567888 + LA FATTURA FA RIFERIMENTO AD UNA OPERAZIONE AAAA BBBBBBBBBBBBBBBBBB CCC DDDDDDDDDDDDDDD E + FFFFFFFFFFFFFFFFFFFF GGGGGGGGGG HHHHHHH II LLLLLLLLLLLLLLLLL MMM NNNNN OO PPPPPPPPPPP QQQQ RRRR + SSSSSSSSSSSSSS + + SEGUE DESCRIZIONE CAUSALE NEL CASO IN CUI NON SIANO STATI SUFFICIENTI 200 CARATTERI AAAAAAAAAAA + BBBBBBBBBBBBBBBBB + + + + 16 + 1 + 2025-05-22 + 3 + 5 + 665544 + 5554466 + + + 2 + 15 + 2025-05-21 + 4 + 4 + 5678 + 1234 + + + + + IT + 24681012141 + + + Trasporto spa + + + 2012-10-22T16:46:12.000+02:00 + + + + + 1 + Cool stuff + 5.00 + 1.00 + 5.00 + 22.00 + + + 2 + OtherAccount + 3.00 + 8.00 + 24.00 + 22.00 + + + 3 + GuessTaxes + 1.00 + 10.00 + 10.00 + + + 22.00 + 29.00 + 6.38 + I + + + + TP01 + + MP01 + 2015-01-30 + 36.48 + + + + diff --git a/l10n_it_edi_sender_partner/tests/test_export_xml.py b/l10n_it_edi_sender_partner/tests/test_export_xml.py new file mode 100644 index 000000000000..2039391231c7 --- /dev/null +++ b/l10n_it_edi_sender_partner/tests/test_export_xml.py @@ -0,0 +1,49 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.fields import Command + +from odoo.addons.l10n_it_edi.tests.common import TestItEdi + + +class TestItEdiExport(TestItEdi): + """Test export of invoice with sender partner""" + + def test_export_with_sender(self): + """Test that TerzoIntermediarioOSoggettoEmittente is in the XML""" + sender = self.env["res.partner"].create( + { + "name": "Intermediario Srl", + "vat": "IT12345670017", + "country_id": self.env.ref("base.it").id, + } + ) + self.company.l10n_edi_it_sender_partner = sender + + invoice = ( + self.env["account.move"] + .with_company(self.company) + .create( + { + "move_type": "out_invoice", + "partner_id": self.italian_partner_a.id, + "invoice_date": "2024-01-15", + "invoice_line_ids": [ + Command.create( + { + "name": "Test product", + "quantity": 1, + "price_unit": 100.0, + "tax_ids": [Command.set(self.default_tax.ids)], + }, + ) + ], + } + ) + ) + invoice.action_post() + + xml_content = invoice._l10n_it_edi_render_xml().decode() + + self.assertIn("TerzoIntermediarioOSoggettoEmittente", xml_content) + self.assertIn("12345670017", xml_content) + self.assertIn("TZ", xml_content) diff --git a/l10n_it_edi_sender_partner/tests/test_import_xml.py b/l10n_it_edi_sender_partner/tests/test_import_xml.py new file mode 100644 index 000000000000..4e502f97448f --- /dev/null +++ b/l10n_it_edi_sender_partner/tests/test_import_xml.py @@ -0,0 +1,38 @@ +from odoo import fields + +from odoo.addons.l10n_it_edi.tests.common import TestItEdi + + +class TestItEdiImport(TestItEdi): + """Main test class for the l10n_it_edi vendor bills XML import""" + + @classmethod + def setUpClass(cls): + super().setUpClass() + # sender partner atteso nell’XML + cls.intermediary_partner = cls.env["res.partner"].create( + { + "name": "INTERMEDIARIO SRL", + "vat": "IT12345670017", + "country_id": cls.env.ref("base.it").id, + } + ) + + def test_receive_vendor_bill(self): + """Test a sample e-invoice file with an intermediary""" + self.module = "l10n_it_edi_sender_partner" + invoice = self._assert_import_invoice( + "IT01234567888_FPR01_02.xml", + [ + { + "move_type": "in_invoice", + "invoice_date": fields.Date.from_string("2014-12-18"), + "amount_untaxed": 39.0, + "amount_tax": 6.38, + } + ], + ) + l10n_it_edi_intermediary_id = invoice.l10n_it_edi_intermediary_id + self.assertTrue(l10n_it_edi_intermediary_id) + self.assertEqual(l10n_it_edi_intermediary_id.vat, "IT12345670017") + self.assertEqual(l10n_it_edi_intermediary_id.display_name, "INTERMEDIARIO SRL") diff --git a/l10n_it_edi_sender_partner/views/account_view.xml b/l10n_it_edi_sender_partner/views/account_view.xml new file mode 100644 index 000000000000..6259e3ccf74d --- /dev/null +++ b/l10n_it_edi_sender_partner/views/account_view.xml @@ -0,0 +1,13 @@ + + + + account.invoice.intermediary + account.move + + + + + + + + diff --git a/l10n_it_edi_sender_partner/views/l10n_it_sender_partner.xml b/l10n_it_edi_sender_partner/views/l10n_it_sender_partner.xml new file mode 100644 index 000000000000..5f2bc813516a --- /dev/null +++ b/l10n_it_edi_sender_partner/views/l10n_it_sender_partner.xml @@ -0,0 +1,39 @@ + + + + diff --git a/l10n_it_edi_sender_partner/views/l10n_it_view.xml b/l10n_it_edi_sender_partner/views/l10n_it_view.xml new file mode 100644 index 000000000000..17015f6bc780 --- /dev/null +++ b/l10n_it_edi_sender_partner/views/l10n_it_view.xml @@ -0,0 +1,16 @@ + + + + res.company.form.l10n.it.sender.view + res.company + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000000..f887f7cef7a3 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-l10n_it_edi_extension @ git+https://github.com/OCA/l10n-italy@refs/pull/5083/head#subdirectory=l10n_it_edi_extension