diff --git a/l10n_it_fatturapa_import_zip/tests/data/xml_import.zip b/l10n_it_fatturapa_import_zip/tests/data/xml_import.zip index f32f41b58d46..d9f9f6e479ff 100644 Binary files a/l10n_it_fatturapa_import_zip/tests/data/xml_import.zip and b/l10n_it_fatturapa_import_zip/tests/data/xml_import.zip differ diff --git a/l10n_it_fatturapa_in/tests/data/IT05979361218_003.xml b/l10n_it_fatturapa_in/tests/data/IT05979361218_003.xml index 240035ebebbe..9a3f65ef0eb7 100644 --- a/l10n_it_fatturapa_in/tests/data/IT05979361218_003.xml +++ b/l10n_it_fatturapa_in/tests/data/IT05979361218_003.xml @@ -53,7 +53,7 @@ xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1. IT 03533590174 - MRORSS90E25B111T + MRORSS90E25B111K MARIO ROSSI diff --git a/l10n_it_fatturapa_in/tests/data/IT05979361218_004.xml b/l10n_it_fatturapa_in/tests/data/IT05979361218_004.xml index fc0442860da3..f53382d25691 100644 --- a/l10n_it_fatturapa_in/tests/data/IT05979361218_004.xml +++ b/l10n_it_fatturapa_in/tests/data/IT05979361218_004.xml @@ -53,7 +53,7 @@ xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1. IT 03533590174 - MRORSS90E25B111T + MRORSS90E25B111K MARIO ROSSI diff --git a/l10n_it_fiscalcode/README.rst b/l10n_it_fiscalcode/README.rst index 6f22a0636c55..360e301d88eb 100644 --- a/l10n_it_fiscalcode/README.rst +++ b/l10n_it_fiscalcode/README.rst @@ -85,13 +85,13 @@ fragment is included. ] 16.0.1.0.0 (2022-11-11) ----------------------- -- [MIG] Migration from Odoo 14.0 to 16.0 -- [IMP] Black, isort, prettier (pre-commit) +- [MIG] Migration from Odoo 14.0 to 16.0 +- [IMP] Black, isort, prettier (pre-commit) 16.0.1.0.1 (2022-11-16) ----------------------- -- [IMP] Add codicefiscale.isvalid() to improve fiscalcode validation +- [IMP] Add codicefiscale.isvalid() to improve fiscalcode validation Bug Tracker =========== @@ -116,25 +116,25 @@ Authors Contributors ------------ -- Davide Corio -- Luca Subiaco -- Simone Orsi -- Mario Riva -- Mauro Soligo -- Giovanni Barzan -- Lorenzo Battistini -- Roberto Onnis -- Franco Tampieri -- Andrea Cometa -- Andrea Gallina -- Matteo Bilotta -- Giuseppe Borruso - Dinamiche Aziendali srl - -- Alex Comba -- Marco Colombo -- `Aion Tech `__: - - - Simone Rubino +- Davide Corio +- Luca Subiaco +- Simone Orsi +- Mario Riva +- Mauro Soligo +- Giovanni Barzan +- Lorenzo Battistini +- Roberto Onnis +- Franco Tampieri +- Andrea Cometa +- Andrea Gallina +- Matteo Bilotta +- Giuseppe Borruso - Dinamiche Aziendali srl + +- Alex Comba +- Marco Colombo +- `Aion Tech `__: + + - Simone Rubino Maintainers ----------- diff --git a/l10n_it_fiscalcode/__manifest__.py b/l10n_it_fiscalcode/__manifest__.py index e0acbb125cb1..46d1eb498c9d 100644 --- a/l10n_it_fiscalcode/__manifest__.py +++ b/l10n_it_fiscalcode/__manifest__.py @@ -18,7 +18,7 @@ "license": "AGPL-3", "depends": ["account"], "external_dependencies": { - "python": ["codicefiscale"], + "python": ["python-codicefiscale"], }, "data": [ "security/ir.model.access.csv", diff --git a/l10n_it_fiscalcode/model/res_partner.py b/l10n_it_fiscalcode/model/res_partner.py index a23bd557b57f..99e2a66f932a 100644 --- a/l10n_it_fiscalcode/model/res_partner.py +++ b/l10n_it_fiscalcode/model/res_partner.py @@ -1,7 +1,7 @@ # Copyright 2024 Simone Rubino - Aion Tech # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from codicefiscale import isvalid +from codicefiscale import codicefiscale from odoo import _, api, fields, models from odoo.exceptions import ValidationError @@ -30,7 +30,7 @@ def check_fiscalcode(self): # Check fiscalcode length of a person msg = _("The fiscal code must have 16 characters.") raise ValidationError(msg) - if not isvalid(partner.fiscalcode): + if not codicefiscale.is_valid(partner.fiscalcode): # Check fiscalcode validity msg = _("The fiscal code isn't valid.") raise ValidationError(msg) diff --git a/l10n_it_fiscalcode/static/description/index.html b/l10n_it_fiscalcode/static/description/index.html index e111620ba3a6..8946534656a6 100644 --- a/l10n_it_fiscalcode/static/description/index.html +++ b/l10n_it_fiscalcode/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -484,7 +485,9 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +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.

diff --git a/l10n_it_fiscalcode/tests/test_fiscalcode.py b/l10n_it_fiscalcode/tests/test_fiscalcode.py index dbbcbd4713a2..e6a206f8682f 100644 --- a/l10n_it_fiscalcode/tests/test_fiscalcode.py +++ b/l10n_it_fiscalcode/tests/test_fiscalcode.py @@ -1,7 +1,7 @@ # Copyright 2024 Simone Rubino - Aion Tech # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from codicefiscale import isvalid +from codicefiscale import codicefiscale from odoo.exceptions import ValidationError from odoo.tests.common import TransactionCase @@ -75,6 +75,16 @@ def test_fiscalcode_check(self): "fiscalcode": "AAAMRA00H04H5010", } ) + # Omocode FC - Test if an omocode fiscalcode is considered valid + # Fiscalcode in this test is get from + # https://pypi.org/project/python-codicefiscale/ examples + self.env["res.partner"].create( + { + "name": "Person", + "is_company": False, + "fiscalcode": "CCCFBA85D03L21VE", + } + ) def test_fiscal_code_check_change_to_person(self): """ @@ -91,7 +101,7 @@ def test_fiscal_code_check_change_to_person(self): ) partner.fiscalcode = wrong_person_fiscalcode # pre-condition - self.assertFalse(isvalid(partner.fiscalcode)) + self.assertFalse(codicefiscale.is_valid(partner.fiscalcode)) # Act with self.assertRaises(ValidationError) as ve: @@ -118,7 +128,7 @@ def test_fiscal_code_check_company_VAT_change_to_person(self): ) partner.fiscalcode = company_vat # pre-condition - self.assertFalse(isvalid(partner.fiscalcode)) + self.assertFalse(codicefiscale.is_valid(partner.fiscalcode)) # Act with self.assertRaises(ValidationError) as ve: diff --git a/l10n_it_fiscalcode/wizard/compute_fc.py b/l10n_it_fiscalcode/wizard/compute_fc.py index 2271a985df4a..307b52fb5cad 100644 --- a/l10n_it_fiscalcode/wizard/compute_fc.py +++ b/l10n_it_fiscalcode/wizard/compute_fc.py @@ -1,23 +1,16 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import datetime import logging +from codicefiscale import codicefiscale + from odoo import _, api, fields, models from odoo.exceptions import UserError from odoo.osv import expression _logger = logging.getLogger(__name__) -try: - from codicefiscale import build - -except ImportError: - _logger.warning( - "codicefiscale library not found. " - "If you plan to use it, please install the codicefiscale library" - " from https://pypi.python.org/pypi/codicefiscale" - ) - class WizardComputeFc(models.TransientModel): _name = "wizard.compute.fc" @@ -185,16 +178,23 @@ def compute_fc(self): or not f.sex ): raise UserError(_("One or more fields are missing")) + nat_code = self._get_national_code( f.birth_city.name, f.birth_province.code, f.birth_date ) if not nat_code: raise UserError(_("National code is missing")) - c_f = build( + + if isinstance(f.birth_date, datetime.date): + birth_date = f.birth_date.strftime("%d/%m/%Y") + else: + birth_date = f.birth_date + + c_f = codicefiscale.encode( f.fiscalcode_surname, f.fiscalcode_firstname, - f.birth_date, f.sex, + birth_date, nat_code, ) if partner.fiscalcode and partner.fiscalcode != c_f: diff --git a/requirements.txt b/requirements.txt index 7052f10569c4..f66bf0b0d4e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ # generated from manifests external_dependencies asn1crypto -codicefiscale elementpath mock openupgradelib +python-codicefiscale unidecode xmlschema