Skip to content

Commit

Permalink
Merge PR #3406 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by OpenCode
  • Loading branch information
OCA-git-bot committed Oct 6, 2023
2 parents 0a1db2b + 3d3d997 commit e18a156
Show file tree
Hide file tree
Showing 16 changed files with 879 additions and 0 deletions.
68 changes: 68 additions & 0 deletions l10n_it_website_portal_fatturapa/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/l10n-italy/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 <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_website_portal_fatturapa%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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 <https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_website_portal_fatturapa>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions l10n_it_website_portal_fatturapa/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2019 Simone Rubino
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import controllers
26 changes: 26 additions & 0 deletions l10n_it_website_portal_fatturapa/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
3 changes: 3 additions & 0 deletions l10n_it_website_portal_fatturapa/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import main
90 changes: 90 additions & 0 deletions l10n_it_website_portal_fatturapa/controllers/main.py
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions l10n_it_website_portal_fatturapa/i18n/it.po
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>\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"
Original file line number Diff line number Diff line change
@@ -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 ""

1 change: 1 addition & 0 deletions l10n_it_website_portal_fatturapa/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow frontend users to edit any necessary field for Electronic invoice from their *details* page.
1 change: 1 addition & 0 deletions l10n_it_website_portal_fatturapa/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e18a156

Please sign in to comment.