Skip to content

Commit

Permalink
[IMP] l10n_it_fiscalcode: update library to check fiscalcode
Browse files Browse the repository at this point in the history
Update library to check if a partner fiscal is formally valid,
using python-codicefiscale library that can validate a fiscalcode
even if this is omocode
  • Loading branch information
patrickt-oforce committed Dec 16, 2024
1 parent 0460d06 commit 195b32e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 30 deletions.
44 changes: 22 additions & 22 deletions l10n_it_fiscalcode/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand All @@ -116,25 +116,25 @@ Authors
Contributors
------------

- Davide Corio
- Luca Subiaco <subluca@gmail.com>
- Simone Orsi <simone.orsi@domsense.com>
- Mario Riva <mario.riva@agilebg.com>
- Mauro Soligo <mauro.soligo@katodo.com>
- Giovanni Barzan <giovanni.barzan@gmail.com>
- Lorenzo Battistini <lorenzo.battistini@agilebg.com>
- Roberto Onnis <onnis.roberto@gmail.com>
- Franco Tampieri
- Andrea Cometa <info@andreacometa.it>
- Andrea Gallina
- Matteo Bilotta <mbilotta@linkgroup.it>
- Giuseppe Borruso - Dinamiche Aziendali srl
<gborruso@dinamicheaziendali.it>
- Alex Comba <alex.comba@agilebg.com>
- Marco Colombo <marco.colombo@phi.technology>
- `Aion Tech <https://aiontech.company/>`__:

- Simone Rubino <simone.rubino@aion-tech.it>
- Davide Corio
- Luca Subiaco <subluca@gmail.com>
- Simone Orsi <simone.orsi@domsense.com>
- Mario Riva <mario.riva@agilebg.com>
- Mauro Soligo <mauro.soligo@katodo.com>
- Giovanni Barzan <giovanni.barzan@gmail.com>
- Lorenzo Battistini <lorenzo.battistini@agilebg.com>
- Roberto Onnis <onnis.roberto@gmail.com>
- Franco Tampieri
- Andrea Cometa <info@andreacometa.it>
- Andrea Gallina
- Matteo Bilotta <mbilotta@linkgroup.it>
- Giuseppe Borruso - Dinamiche Aziendali srl
<gborruso@dinamicheaziendali.it>
- Alex Comba <alex.comba@agilebg.com>
- Marco Colombo <marco.colombo@phi.technology>
- `Aion Tech <https://aiontech.company/>`__:

- Simone Rubino <simone.rubino@aion-tech.it>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_fiscalcode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"license": "AGPL-3",
"depends": ["account"],
"external_dependencies": {
"python": ["codicefiscale"],
"python": ["python-codicefiscale"],
},
"data": [
"security/ir.model.access.csv",
Expand Down
4 changes: 2 additions & 2 deletions l10n_it_fiscalcode/model/res_partner.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions l10n_it_fiscalcode/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -484,7 +485,9 @@ <h2><a class="toc-backref" href="#toc-entry-9">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
10 changes: 10 additions & 0 deletions l10n_it_fiscalcode/tests/test_fiscalcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# generated from manifests external_dependencies
asn1crypto
codicefiscale
elementpath
mock
openupgradelib
python-codicefiscale
unidecode
xmlschema

0 comments on commit 195b32e

Please sign in to comment.