Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] l10n_it_website_portal_fatturapa #2520

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
===================================
ITA - 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/14.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-14-0/l10n-italy-14-0-l10n_it_website_portal_fatturapa
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/122/14.0
:alt: Try me on Runbot

|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:%2014.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/14.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
19 changes: 19 additions & 0 deletions l10n_it_website_portal_fatturapa/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2019 Simone Rubino
# Copyright 2019 Lorenzo Battistini
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "ITA - Fattura elettronica - Portale",
"summary": "Add fatturapa fields and checks in frontend user's details",
"version": "14.0.1.0.0",
"author": "Odoo Community Association (OCA)",
"category": "Localization/Italy",
"website": "https://github.com/OCA/l10n-italy",
"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"],
"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(

Check warning on line 36 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L36

Added line #L36 was not covered by tests
"electronic_invoice_subjected", False
)
if data["electronic_invoice_subjected"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cosa ne pensi di trasformare questo blocco in

    if data["electronic_invoice_subjected"]:
        data["electronic_invoice_obliged_subject"] = True
        country_italy = request.env.ref('base.it', raise_if_not_found=False)
        country_id = data.get('country_id', False)
        if country_id and country_italy and int(country_id) != country_italy.id:
            data["codice_destinatario"] = "XXXXXXX"
        elif data.get('codice_destinatario') == "XXXXXXX":
            data["codice_destinatario"] = "0000000"

? per via di questo #2520 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fatto

Copy link
Contributor

@FrancescoBallerini FrancescoBallerini Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Borruso Grazie, un ultimo appunto è che si potrebbe importare il codice destinatario standard con "0000000" da qui https://github.com/OCA/l10n-italy/blob/14.0/l10n_it_fatturapa/models/partner.py#L7 , ma non so se ne vale la pena, decidete voi 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Borruso Grazie, un ultimo appunto è che si potrebbe importare il codice destinatario standard con "0000000" da qui https://github.com/OCA/l10n-italy/blob/14.0/l10n_it_fatturapa/models/partner.py#L7 , ma non so se ne vale la pena, decidete voi 👍

puoi aprire una issue per tenerne traccia

data["electronic_invoice_obliged_subject"] = True
error, error_message = super(

Check warning on line 41 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L40-L41

Added lines #L40 - L41 were not covered by tests
WebsitePortalFatturapa, self
).details_form_validate(data)
partner_sudo = request.env.user.partner_id.sudo()
error, error_message = self.validate_partner_firstname(

Check warning on line 45 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L44-L45

Added lines #L44 - L45 were not covered by tests
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

Check warning on line 56 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L49-L56

Added lines #L49 - L56 were not covered by tests

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]

Check warning on line 61 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L60-L61

Added lines #L60 - L61 were not covered by tests

# 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

Check warning on line 71 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L68-L71

Added lines #L68 - L71 were not covered by tests

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")

Check warning on line 77 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L76-L77

Added lines #L76 - L77 were not covered by tests
if lastname or firstname:
data.update(

Check warning on line 79 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L79

Added line #L79 was not covered by tests
name=request.env["res.partner"]._get_computed_name(
lastname, firstname
)
)
else:
error["firstname"] = "error"
error["lastname"] = "error"
error_message.append(

Check warning on line 87 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L85-L87

Added lines #L85 - L87 were not covered by tests
_("At least one of first name and last name is required")
)
return error, error_message

Check warning on line 90 in l10n_it_website_portal_fatturapa/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_website_portal_fatturapa/controllers/main.py#L90

Added line #L90 was not covered by tests
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.
Copy link
Contributor

@francesco-ooops francesco-ooops Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Borruso questa sezione si può rimuovere, i due campi sono ora visibili nel portale se l'utente è legato ad un partner di tipo company

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading