diff --git a/l10n_it_website_portal_fatturapa/README.rst b/l10n_it_website_portal_fatturapa/README.rst new file mode 100644 index 000000000000..4ad24f3580a4 --- /dev/null +++ b/l10n_it_website_portal_fatturapa/README.rst @@ -0,0 +1,68 @@ +==================================================== +Italian Localization - Fattura elettronica - Portale +==================================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/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/16.0/l10n_it_website_portal_fatturapa + :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-16-0/l10n-italy-16-0-l10n_it_website_portal_fatturapa + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/l10n-italy&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allow frontend users to edit any necessary field for Electronic invoice from their *details* page. + +**Table of contents** + +.. contents:: + :local: + +Known issues / Roadmap +====================== + +Fields `is_pa` and `ipa_code` are not shown in the frontend because Odoo core always supposes that frontend users are individual, and these fields are only meaningful for companies. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +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_website_portal_fatturapa/__init__.py b/l10n_it_website_portal_fatturapa/__init__.py new file mode 100644 index 000000000000..49c73ea2c845 --- /dev/null +++ b/l10n_it_website_portal_fatturapa/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2019 Simone Rubino +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import controllers diff --git a/l10n_it_website_portal_fatturapa/__manifest__.py b/l10n_it_website_portal_fatturapa/__manifest__.py new file mode 100644 index 000000000000..db458be4af79 --- /dev/null +++ b/l10n_it_website_portal_fatturapa/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright 2019 Simone Rubino +# Copyright 2019 Lorenzo Battistini +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Italian Localization - Fattura elettronica - Portale", + "summary": "Add fatturapa fields and checks in frontend user's details", + "version": "16.0.1.0.0", + "author": "Odoo Community Association (OCA)", + "category": "Localization/Italy", + "website": "https://github.com/OCA/l10n-italy" + "/tree/16.0/l10n_it_website_portal_fatturapa", + "license": "AGPL-3", + "depends": [ + "l10n_it_fatturapa", + "l10n_it_website_portal_fiscalcode", + "l10n_it_website_portal_ipa", + ], + "data": ["views/l10n_it_website_portal_fatturapa_templates.xml"], + "assets": { + "web.assets_frontend": [ + "l10n_it_website_portal_fatturapa/static/" + "src/js/l10n_it_website_portal_fatturapa.js", + ], + }, + "auto_install": True, +} diff --git a/l10n_it_website_portal_fatturapa/controllers/__init__.py b/l10n_it_website_portal_fatturapa/controllers/__init__.py new file mode 100644 index 000000000000..f43232f0128c --- /dev/null +++ b/l10n_it_website_portal_fatturapa/controllers/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import main diff --git a/l10n_it_website_portal_fatturapa/controllers/main.py b/l10n_it_website_portal_fatturapa/controllers/main.py new file mode 100644 index 000000000000..7f982f6860bc --- /dev/null +++ b/l10n_it_website_portal_fatturapa/controllers/main.py @@ -0,0 +1,90 @@ +# Copyright 2019 Simone Rubino +# Copyright 2019 Lorenzo Battistini +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.exceptions import ValidationError +from odoo.http import request +from odoo.tools.translate import _ + +from odoo.addons.l10n_it_website_portal_fiscalcode.controllers.main import ( + WebsitePortalFiscalCode, +) + +FATTURAPA_PORTAL_FIELDS = [ + "codice_destinatario", + "firstname", + "lastname", + "pec_destinatario", + "country_id", + "fiscalcode", + "zipcode", + "vat", + "electronic_invoice_subjected", + "street", + "city", + "is_pa", + "ipa_code", + "eori_code", + "electronic_invoice_obliged_subject", +] +WebsitePortalFiscalCode.OPTIONAL_BILLING_FIELDS.extend(FATTURAPA_PORTAL_FIELDS) + + +class WebsitePortalFatturapa(WebsitePortalFiscalCode): + def details_form_validate(self, data): + # when checkbox electronic_invoice_subjected is not checked, + # it is not posted + data["electronic_invoice_subjected"] = data.get( + "electronic_invoice_subjected", False + ) + if data["electronic_invoice_subjected"]: + data["electronic_invoice_obliged_subject"] = True + error, error_message = super( + WebsitePortalFatturapa, self + ).details_form_validate(data) + partner_sudo = request.env.user.partner_id.sudo() + error, error_message = self.validate_partner_firstname( + data, error, error_message + ) + + partner_values = self.get_portal_fatturapa_partner_values(data, partner_sudo) + dummy_partner = request.env["res.partner"].new(partner_values) + try: + dummy_partner._check_ftpa_partner_data() + except ValidationError as ve: + error["error"] = "error" + error_message.append(ve.name) + return error, error_message + + def get_portal_fatturapa_partner_values(self, data, partner_sudo): + # Read all the fields for the constraint from the current user + constr_fields = partner_sudo._check_ftpa_partner_data._constrains + partner_values = partner_sudo.read(constr_fields)[0] + + # Update them with fields that might be edited by the user + new_partner_values = { + f_name: data.get(f_name) for f_name in FATTURAPA_PORTAL_FIELDS + } + if new_partner_values.get("country_id"): + new_partner_values["country_id"] = int(new_partner_values["country_id"]) + new_partner_values.update({"zip": new_partner_values.pop("zipcode", "")}) + partner_values.update(new_partner_values) + return partner_values + + def validate_partner_firstname(self, data, error, error_message): + # Compute name field, using First name and Last name + if all(f in data for f in ["name", "firstname", "lastname"]): + lastname = data.get("lastname") + firstname = data.get("firstname") + if lastname or firstname: + data.update( + name=request.env["res.partner"]._get_computed_name( + lastname, firstname + ) + ) + else: + error["firstname"] = "error" + error["lastname"] = "error" + error_message.append( + _("At least one of first name and last name is required") + ) + return error, error_message diff --git a/l10n_it_website_portal_fatturapa/i18n/it.po b/l10n_it_website_portal_fatturapa/i18n/it.po new file mode 100644 index 000000000000..8132b8c84479 --- /dev/null +++ b/l10n_it_website_portal_fatturapa/i18n/it.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_website_portal_fatturapa +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-12-09 12:04+0000\n" +"Last-Translator: Lorenzo Battistini \n" +"Language-Team: none\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 3.9.1\n" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Addressee code" +msgstr "Codice destinatario" + +#. module: l10n_it_website_portal_fatturapa +#: code:addons/l10n_it_website_portal_fatturapa/controllers/main.py:72 +#, python-format +msgid "At least one of first name and last name is required" +msgstr "Almeno uno fra nome e cognome รจ richiesto" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "EORI code" +msgstr "Codice EORI" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Enable receiving electronic invoice" +msgstr "Abilitare la ricezione della fattura elettronica" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Or PEC address for Electronic invoicing" +msgstr "O indirizzo PEC per la fatturazione elettronica" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Your First Name" +msgstr "Il tuo nome" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Your Last Name" +msgstr "Il tuo cognome" diff --git a/l10n_it_website_portal_fatturapa/i18n/l10n_it_website_portal_fatturapa.pot b/l10n_it_website_portal_fatturapa/i18n/l10n_it_website_portal_fatturapa.pot new file mode 100644 index 000000000000..b89440edb972 --- /dev/null +++ b/l10n_it_website_portal_fatturapa/i18n/l10n_it_website_portal_fatturapa.pot @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_website_portal_fatturapa +# +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_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Addressee code" +msgstr "" + +#. module: l10n_it_website_portal_fatturapa +#: code:addons/l10n_it_website_portal_fatturapa/controllers/main.py:72 +#, python-format +msgid "At least one of first name and last name is required" +msgstr "" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "EORI code" +msgstr "" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Enable receiving electronic invoice" +msgstr "" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Or PEC address for Electronic invoicing" +msgstr "" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Your First Name" +msgstr "" + +#. module: l10n_it_website_portal_fatturapa +#: model_terms:ir.ui.view,arch_db:l10n_it_website_portal_fatturapa.fatturapa_details +msgid "Your Last Name" +msgstr "" + diff --git a/l10n_it_website_portal_fatturapa/readme/DESCRIPTION.rst b/l10n_it_website_portal_fatturapa/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..5491a9b6b040 --- /dev/null +++ b/l10n_it_website_portal_fatturapa/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Allow frontend users to edit any necessary field for Electronic invoice from their *details* page. diff --git a/l10n_it_website_portal_fatturapa/readme/ROADMAP.rst b/l10n_it_website_portal_fatturapa/readme/ROADMAP.rst new file mode 100644 index 000000000000..ff5071c2dab6 --- /dev/null +++ b/l10n_it_website_portal_fatturapa/readme/ROADMAP.rst @@ -0,0 +1 @@ +Fields `is_pa` and `ipa_code` are not shown in the frontend because Odoo core always supposes that frontend users are individual, and these fields are only meaningful for companies. diff --git a/l10n_it_website_portal_fatturapa/static/description/icon.png b/l10n_it_website_portal_fatturapa/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/l10n_it_website_portal_fatturapa/static/description/icon.png differ diff --git a/l10n_it_website_portal_fatturapa/static/description/index.html b/l10n_it_website_portal_fatturapa/static/description/index.html new file mode 100644 index 000000000000..be6c71e29a3f --- /dev/null +++ b/l10n_it_website_portal_fatturapa/static/description/index.html @@ -0,0 +1,410 @@ + + + + + + +Italian Localization - Fattura elettronica - Portale + + + +
+

Italian Localization - Fattura elettronica - Portale

+ + +

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

+

Allow frontend users to edit any necessary field for Electronic invoice from their details page.

+

Table of contents

+ +
+

Known issues / Roadmap

+

Fields is_pa and ipa_code are not shown in the frontend because Odoo core always supposes that frontend users are individual, and these fields are only meaningful for companies.

+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

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_website_portal_fatturapa/static/src/js/l10n_it_website_portal_fatturapa.js b/l10n_it_website_portal_fatturapa/static/src/js/l10n_it_website_portal_fatturapa.js new file mode 100644 index 000000000000..0bcccf0badfe --- /dev/null +++ b/l10n_it_website_portal_fatturapa/static/src/js/l10n_it_website_portal_fatturapa.js @@ -0,0 +1,50 @@ +odoo.define("l10n_it_website_portal_fatturapa", function (require) { + "use strict"; + require("web.core"); + + $(document).ready(function () { + var details_div_selector = ".o_portal_details"; + var $details_div = $(details_div_selector); + if ($details_div.length) { + var $electronic_invoice_subjected_input = $details_div.find( + "input[name='electronic_invoice_subjected'][type='checkbox']" + ); + var $div_electronic_invoice_subjected_fields = $details_div.find( + ".div_electronic_invoice_subjected_fields" + ); + + var compute_e_inv_fields_visibility = function () { + if ($electronic_invoice_subjected_input[0].checked) { + $div_electronic_invoice_subjected_fields.show(); + } else { + $div_electronic_invoice_subjected_fields.hide(); + } + }; + compute_e_inv_fields_visibility(); + $electronic_invoice_subjected_input.change(compute_e_inv_fields_visibility); + + var $is_pa = $details_div.find("input[name='is_pa'][type='checkbox']"); + if (!$is_pa.length) { + return; + } + var $codice_destinatario_div = $details_div + .find("input[name='codice_destinatario'][type='text']") + .parent(); + var $pec_destinatario_div = $details_div + .find("input[name='pec_destinatario'][type='text']") + .parent(); + + var compute_destinatario_fields_visibility = function () { + if ($is_pa[0].checked) { + $codice_destinatario_div.hide(); + $pec_destinatario_div.hide(); + } else { + $codice_destinatario_div.show(); + $pec_destinatario_div.show(); + } + }; + compute_destinatario_fields_visibility(); + $is_pa.change(compute_destinatario_fields_visibility); + } + }); +}); diff --git a/l10n_it_website_portal_fatturapa/views/l10n_it_website_portal_fatturapa_templates.xml b/l10n_it_website_portal_fatturapa/views/l10n_it_website_portal_fatturapa_templates.xml new file mode 100644 index 000000000000..b2b6a8aa4e9c --- /dev/null +++ b/l10n_it_website_portal_fatturapa/views/l10n_it_website_portal_fatturapa_templates.xml @@ -0,0 +1,114 @@ + + + + + + diff --git a/setup/l10n_it_website_portal_fatturapa/odoo/addons/l10n_it_website_portal_fatturapa b/setup/l10n_it_website_portal_fatturapa/odoo/addons/l10n_it_website_portal_fatturapa new file mode 120000 index 000000000000..7ceee35bd27b --- /dev/null +++ b/setup/l10n_it_website_portal_fatturapa/odoo/addons/l10n_it_website_portal_fatturapa @@ -0,0 +1 @@ +../../../../l10n_it_website_portal_fatturapa \ No newline at end of file diff --git a/setup/l10n_it_website_portal_fatturapa/setup.py b/setup/l10n_it_website_portal_fatturapa/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_it_website_portal_fatturapa/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000000..844aa49e9891 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-l10n_it_website_portal_fiscalcode @ git+https://github.com/OCA/l10n-italy@refs/pull/3338/head#subdirectory=setup/l10n_it_website_portal_fiscalcode