diff --git a/l10n_it_fatturapa_out_oss/README.rst b/l10n_it_fatturapa_out_oss/README.rst new file mode 100644 index 000000000000..69c8c6677f17 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/README.rst @@ -0,0 +1,91 @@ +=========================================== +ITA - Fattura elettronica - Emissione - OSS +=========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:88fe86904abb0356b30b42262b7e64b67957992e2cd4a8321bf89c57f7168ef9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-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/14.0/l10n_it_fatturapa_out_oss + :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-14-0/l10n-italy-14-0-l10n_it_fatturapa_out_oss + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +**Italiano** + +Modulo tecnico di integrazione tra l10n_eu_oss e l10n_it_fatturapa_out + +**English** + +Technical module for integrating l10n_eu_oss and l10n_it_fatturapa_out + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**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 +~~~~~~~ + +* Sergio Corato + +Contributors +~~~~~~~~~~~~ + +* Sergio Corato + +* `TAKOBI `_: + + * Lorenzo Battistini + +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_fatturapa_out_oss/__init__.py b/l10n_it_fatturapa_out_oss/__init__.py new file mode 100644 index 000000000000..f5b388c3a40a --- /dev/null +++ b/l10n_it_fatturapa_out_oss/__init__.py @@ -0,0 +1,13 @@ +from . import wizard +from odoo import api, SUPERUSER_ID + + +def _l10n_it_fatturapa_out_oss_post_init(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + oss_taxes = env["account.tax"].search([("oss_country_id", "!=", False)]) + oss_taxes.write( + { + "kind_id": env.ref("l10n_it_account_tax_kind.n3_2").id, + "law_reference": "Art. 41 D.L. 331/1993", + } + ) diff --git a/l10n_it_fatturapa_out_oss/__manifest__.py b/l10n_it_fatturapa_out_oss/__manifest__.py new file mode 100644 index 000000000000..8795b30e619b --- /dev/null +++ b/l10n_it_fatturapa_out_oss/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2022 Sergio Corato +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "ITA - Fattura elettronica - Emissione - OSS", + "version": "14.0.1.0.0", + "development_status": "Alpha", + "category": "Localization/Italy", + "summary": "OSS in fatturapa", + "author": "Sergio Corato," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-italy", + "license": "AGPL-3", + "depends": [ + "l10n_it_fatturapa_out", + "l10n_eu_oss", + ], + "data": [ + "data/invoice_it_template.xml", + ], + "installable": True, + "auto_install": True, + "post_init_hook": "_l10n_it_fatturapa_out_oss_post_init", +} diff --git a/l10n_it_fatturapa_out_oss/data/invoice_it_template.xml b/l10n_it_fatturapa_out_oss/data/invoice_it_template.xml new file mode 100644 index 000000000000..665c7d5d8498 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/data/invoice_it_template.xml @@ -0,0 +1,71 @@ + + + + + + + + diff --git a/l10n_it_fatturapa_out_oss/i18n/it.po b/l10n_it_fatturapa_out_oss/i18n/it.po new file mode 100644 index 000000000000..bb48c336f679 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/i18n/it.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_out_oss +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-06-22 16:56+0000\n" +"PO-Revision-Date: 2023-04-26 16:05+0000\n" +"Last-Translator: mymage \n" +"Language-Team: \n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: l10n_it_fatturapa_out_oss +#: model:ir.model,name:l10n_it_fatturapa_out_oss.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "Esporta E-fattura" + +#. module: l10n_it_fatturapa_out_oss +#: model:ir.model,name:l10n_it_fatturapa_out_oss.model_l10n_eu_oss_wizard +msgid "l10n.eu.oss.wizard" +msgstr "l10n.eu.oss.wizard" diff --git a/l10n_it_fatturapa_out_oss/i18n/l10n_it_fatturapa_out_oss.pot b/l10n_it_fatturapa_out_oss/i18n/l10n_it_fatturapa_out_oss.pot new file mode 100644 index 000000000000..156b94f3f794 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/i18n/l10n_it_fatturapa_out_oss.pot @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_out_oss +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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_fatturapa_out_oss +#: model:ir.model,name:l10n_it_fatturapa_out_oss.model_wizard_export_fatturapa +msgid "Export E-invoice" +msgstr "" + +#. module: l10n_it_fatturapa_out_oss +#: model:ir.model,name:l10n_it_fatturapa_out_oss.model_l10n_eu_oss_wizard +msgid "l10n.eu.oss.wizard" +msgstr "" + diff --git a/l10n_it_fatturapa_out_oss/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_out_oss/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..93b7071d7825 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Sergio Corato + +* `TAKOBI `_: + + * Lorenzo Battistini diff --git a/l10n_it_fatturapa_out_oss/readme/DESCRIPTION.rst b/l10n_it_fatturapa_out_oss/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..111d9fb76340 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +**Italiano** + +Modulo tecnico di integrazione tra l10n_eu_oss e l10n_it_fatturapa_out + +**English** + +Technical module for integrating l10n_eu_oss and l10n_it_fatturapa_out diff --git a/l10n_it_fatturapa_out_oss/static/description/icon.png b/l10n_it_fatturapa_out_oss/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/l10n_it_fatturapa_out_oss/static/description/icon.png differ diff --git a/l10n_it_fatturapa_out_oss/static/description/index.html b/l10n_it_fatturapa_out_oss/static/description/index.html new file mode 100644 index 000000000000..9af231b5aaf4 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +ITA - Fattura elettronica - Emissione - OSS + + + +
+

ITA - Fattura elettronica - Emissione - OSS

+ + +

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

+

Italiano

+

Modulo tecnico di integrazione tra l10n_eu_oss e l10n_it_fatturapa_out

+

English

+

Technical module for integrating l10n_eu_oss and l10n_it_fatturapa_out

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

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

+
    +
  • Sergio Corato
  • +
+
+
+

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_fatturapa_out_oss/tests/__init__.py b/l10n_it_fatturapa_out_oss/tests/__init__.py new file mode 100644 index 000000000000..c4c14b87a47c --- /dev/null +++ b/l10n_it_fatturapa_out_oss/tests/__init__.py @@ -0,0 +1,2 @@ +from . import fatturapa_common +from . import test_fatturapa_xml_validation diff --git a/l10n_it_fatturapa_out_oss/tests/data/IT06363391001_00001.xml b/l10n_it_fatturapa_out_oss/tests/data/IT06363391001_00001.xml new file mode 100644 index 000000000000..e3a977f39d03 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/tests/data/IT06363391001_00001.xml @@ -0,0 +1,106 @@ + + + + + + IT + 06363391001 + + 00001 + FPR12 + XXXXXXX + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 06363391001 + + + company_1_data + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + AT + 99999999999 + + + EU + B2C Customer + + + + 11 Wien St + 00000 + Wolfsgraben + EE + AT + + + + + + + TD01 + EUR + 2022-02-28 + INV/2022/02/0001 + 16.80 + + + + + 1 + Cabinet with Doors + 1.00 + Units + 14.00000 + 14.00 + 0.00 + N3.2 + + OSS + 20.00 + + + + 0.00 + N3.2 + 14.00 + 0.00 + NON IMPONIBILE ART. 41 COMMA 1, LETT. B + + + + TP02 + + MP05 + 2022-03-31 + 16.80 + + + + diff --git a/l10n_it_fatturapa_out_oss/tests/data/IT06363391001_00002.xml b/l10n_it_fatturapa_out_oss/tests/data/IT06363391001_00002.xml new file mode 100644 index 000000000000..ea05525d5c75 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/tests/data/IT06363391001_00002.xml @@ -0,0 +1,98 @@ + + + + + + IT + 06363391001 + + 00002 + FPR12 + XXXXXXX + + 06543534343 + info@yourcompany.example.com + + + + + + IT + 06363391001 + + + company_1_data + + RF01 + + + Via Milano, 1 + 00100 + Roma + AK + IT + + + 06543534343 + info@yourcompany.example.com + + + + + + AT + 99999999999 + + + EU + B2C Customer + + + + 11 Wien St + 00000 + Wolfsgraben + EE + AT + + + + + + + TD01 + EUR + 2023-02-28 + INV/2023/02/0001 + 17.08 + + + + + 1 + Cabinet with Doors + 1.00 + Units + 14.00000 + 14.00 + 22.00 + + + 22.00 + 14.00 + 3.08 + + + + TP02 + + MP05 + 2023-03-31 + 17.08 + + + + diff --git a/l10n_it_fatturapa_out_oss/tests/fatturapa_common.py b/l10n_it_fatturapa_out_oss/tests/fatturapa_common.py new file mode 100644 index 000000000000..bc9b86919ee8 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/tests/fatturapa_common.py @@ -0,0 +1,18 @@ +from odoo.addons.l10n_it_fatturapa_out.tests.fatturapa_common import ( + FatturaPACommon as _FatturaPACommon, +) + + +class FatturaPACommon(_FatturaPACommon): + def setUp(self): + super().setUp() + + def getAttachment(self, name, module_name=None): + if module_name is None: + module_name = "l10n_it_fatturapa_out_oss" + return super().getAttachment(name, module_name) + + def getFile(self, filename, module_name=None): + if module_name is None: + module_name = "l10n_it_fatturapa_out_oss" + return super().getFile(filename, module_name) diff --git a/l10n_it_fatturapa_out_oss/tests/test_fatturapa_xml_validation.py b/l10n_it_fatturapa_out_oss/tests/test_fatturapa_xml_validation.py new file mode 100644 index 000000000000..2ed40a67d0c8 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/tests/test_fatturapa_xml_validation.py @@ -0,0 +1,114 @@ +# Copyright 2022 Sergio Corato +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import base64 + +from odoo import fields +from odoo.tests import Form, tagged + +from .fatturapa_common import FatturaPACommon + + +@tagged("post_install", "-at_install") +class TestInvoiceOss(FatturaPACommon): + def setUp(self): + super().setUp() + + self.env.company.vat = "IT06363391001" + self.env.company.fatturapa_art73 = False + self.env.company.partner_id.street = "Via Milano, 1" + self.env.company.partner_id.city = "Roma" + self.env.company.partner_id.state_id = self.env.ref("base.state_us_2").id + self.env.company.partner_id.zip = "00100" + self.env.company.partner_id.phone = "06543534343" + self.env.company.email = "info@yourcompany.example.com" + self.env.company.partner_id.country_id = self.env.ref("base.it").id + self.env.company.fatturapa_fiscal_position_id = self.env.ref( + "l10n_it_fatturapa.fatturapa_RF01" + ).id + + self.product_product_10.write({"taxes_id": [(6, 0, self.tax_22.ids)]}) + + tax1_form = Form(self.env["account.tax"]) + tax1_form.name = "OSS AU" + tax1_form.amount = 20.0 + tax1_form.kind_id = self.env.ref("l10n_it_account_tax_kind.n3_2") + tax1_form.law_reference = "NON IMPONIBILE ART. 41 COMMA 1, LETT. B" + self.tax1 = tax1_form.save() + self.tax1.oss_country_id = self.env.ref("base.at").id + + fp_form = Form(self.env["account.fiscal.position"]) + fp_form.name = "OSS Test" + with fp_form.tax_ids.new() as tax_form: + tax_form.tax_src_id = self.tax_22 + tax_form.tax_dest_id = self.tax1 + self.fiscal_position = fp_form.save() + + self.eu_b2c_customer = self.env["res.partner"].create( + { + "name": "EU B2C Customer", + "customer_rank": 1, + "is_company": False, + "street": "11 Wien St", + "is_pa": False, + "city": "Wolfsgraben", + "zip": "12345", + "country_id": self.env.ref("base.at").id, + "codice_destinatario": "XXXXXXX", + } + ) + + def _create_invoice(self, date): + move_form = Form( + self.env["account.move"].with_context(default_move_type="out_invoice") + ) + move_form.invoice_date = fields.Date.from_string(date) + move_form.partner_id = self.eu_b2c_customer + move_form.invoice_payment_term_id = self.env.ref( + "account.account_payment_term_end_following_month" + ) + with move_form.invoice_line_ids.new() as line_form: + line_form.product_id = self.product_product_10 + line_form.quantity = 1 + line_form.product_uom_id = self.product_uom_unit + line_form.price_unit = 14.0 + line_form.account_id = self.a_sale + line_form.tax_ids.add(self.tax_22) + account_move = move_form.save() + return account_move + + def test_1_oss_xml_export(self): + date = "2022-02-28" + invoice = self._create_invoice(date) + move_form = Form(invoice) + move_form.fiscal_position_id = self.fiscal_position + with move_form.invoice_line_ids.edit(0) as line_form: + line_form.tax_ids.clear() + line_form.tax_ids.add(self.tax1) + invoice = move_form.save() + self.assertEqual( + fields.first(invoice.invoice_line_ids).tax_ids[:1].name, + self.tax1.name, + ) + invoice.action_post() + + res = self.run_wizard(invoice.id) + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00001.xml") + xml_content = base64.decodebytes(attachment.datas) + self.check_content(xml_content, "IT06363391001_00001.xml") + + def test_2_oss_xml_export(self): + date = "2023-02-28" + invoice = self._create_invoice(date) + self.assertEqual( + fields.first(invoice.invoice_line_ids).tax_ids[:1].name, + self.tax_22.name, + ) + invoice.action_post() + + res = self.run_wizard(invoice.id) + attachment = self.attach_model.browse(res["res_id"]) + self.set_e_invoice_file_id(attachment, "IT06363391001_00002.xml") + xml_content = base64.decodebytes(attachment.datas) + self.check_content(xml_content, "IT06363391001_00002.xml") diff --git a/l10n_it_fatturapa_out_oss/wizard/__init__.py b/l10n_it_fatturapa_out_oss/wizard/__init__.py new file mode 100644 index 000000000000..d16abc16e349 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/wizard/__init__.py @@ -0,0 +1,2 @@ +from . import l10n_eu_oss_wizard +from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_out_oss/wizard/l10n_eu_oss_wizard.py b/l10n_it_fatturapa_out_oss/wizard/l10n_eu_oss_wizard.py new file mode 100644 index 000000000000..38e873a9778b --- /dev/null +++ b/l10n_it_fatturapa_out_oss/wizard/l10n_eu_oss_wizard.py @@ -0,0 +1,12 @@ +from odoo import models + + +class L10nEuOssWizard(models.TransientModel): + _inherit = "l10n.eu.oss.wizard" + + def _prepare_tax_vals(self, country, tax, rate, tax_group): + vals = super(L10nEuOssWizard, self)._prepare_tax_vals( + country, tax, rate, tax_group + ) + vals["kind_id"] = self.env.ref("l10n_it_account_tax_kind.n3_2").id + return vals diff --git a/l10n_it_fatturapa_out_oss/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_oss/wizard/wizard_export_fatturapa.py new file mode 100644 index 000000000000..b284b2906636 --- /dev/null +++ b/l10n_it_fatturapa_out_oss/wizard/wizard_export_fatturapa.py @@ -0,0 +1,13 @@ +from odoo import api, models + + +class WizardExportFatturapa(models.TransientModel): + _inherit = "wizard.export.fatturapa" + + @api.model + def getAllTaxes(self, invoice): + out = super().getAllTaxes(invoice) + for tax_line_id in out: + tax_line = self.env["account.tax"].browse(tax_line_id) + out[tax_line_id]["Oss Country"] = tax_line.oss_country_id + return out diff --git a/setup/l10n_it_fatturapa_out_oss/odoo/addons/l10n_it_fatturapa_out_oss b/setup/l10n_it_fatturapa_out_oss/odoo/addons/l10n_it_fatturapa_out_oss new file mode 120000 index 000000000000..430c9cd9710e --- /dev/null +++ b/setup/l10n_it_fatturapa_out_oss/odoo/addons/l10n_it_fatturapa_out_oss @@ -0,0 +1 @@ +../../../../l10n_it_fatturapa_out_oss \ No newline at end of file diff --git a/setup/l10n_it_fatturapa_out_oss/setup.py b/setup/l10n_it_fatturapa_out_oss/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_it_fatturapa_out_oss/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)