diff --git a/l10n_fr_hr_check_ssnid/README.rst b/l10n_fr_hr_check_ssnid/README.rst new file mode 100644 index 000000000..2a3f709ec --- /dev/null +++ b/l10n_fr_hr_check_ssnid/README.rst @@ -0,0 +1,105 @@ +================================================== +French Localization - Check Social Security Number +================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:eacb3f41a35a03bd39149b39593ff365efadd6e7b5c7647be962901a57f010c9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png + :target: https://odoo-community.org/page/development-status + :alt: Mature +.. |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--france-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-france/tree/18.0/l10n_fr_hr_check_ssnid + :alt: OCA/l10n-france +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-france-18-0/l10n-france-18-0-l10n_fr_hr_check_ssnid + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-france&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +With this module, the social security number of employees of French +companies will be checked: if the length or checksum is wrong, an error +message will be displayed. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module require the Python +`stdnum `__ library. To install +it, run: + +:: + + pip3 install python-stdnum + +Usage +===== + +Check that the country of the company is **France**. Go to the menu +*Employees > Employees*, select an employee. In the tab *Private +Information*, enter the French social security number in the field *SSN +No*. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Akretion + +Contributors +------------ + +- Alexis de Lattre + +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. + +.. |maintainer-alexis-via| image:: https://github.com/alexis-via.png?size=40px + :target: https://github.com/alexis-via + :alt: alexis-via + +Current `maintainer `__: + +|maintainer-alexis-via| + +This module is part of the `OCA/l10n-france `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_fr_hr_check_ssnid/__init__.py b/l10n_fr_hr_check_ssnid/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_fr_hr_check_ssnid/__manifest__.py b/l10n_fr_hr_check_ssnid/__manifest__.py new file mode 100644 index 000000000..ab5dffa82 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2018-2020 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "French Localization - Check Social Security Number", + "version": "18.0.1.0.0", + "category": "Human Resources", + "development_status": "Mature", + "license": "AGPL-3", + "summary": "Check validity of Social Security Numbers in French companies", + "author": "Akretion,Odoo Community Association (OCA)", + "maintainers": ["alexis-via"], + "website": "https://github.com/OCA/l10n-france", + "depends": ["hr"], + "external_dependencies": {"python": ["python-stdnum"]}, + "installable": True, +} diff --git a/l10n_fr_hr_check_ssnid/i18n/es.po b/l10n_fr_hr_check_ssnid/i18n/es.po new file mode 100644 index 000000000..9b394dee8 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/i18n/es.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_fr_hr_check_ssnid +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-16 21:34+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\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 4.17\n" + +#. module: l10n_fr_hr_check_ssnid +#: model:ir.model,name:l10n_fr_hr_check_ssnid.model_hr_employee +msgid "Employee" +msgstr "Empleado/a" + +#. module: l10n_fr_hr_check_ssnid +#. odoo-python +#: code:addons/l10n_fr_hr_check_ssnid/models/hr_employee.py:0 +#, python-format +msgid "The French Social Security Number '%(ssnid)s' is invalid. (%(e)s)" +msgstr "El número de seguridad social francés '%(ssnid)s' no es válido. (%(e)s)" diff --git a/l10n_fr_hr_check_ssnid/i18n/fr.po b/l10n_fr_hr_check_ssnid/i18n/fr.po new file mode 100644 index 000000000..4de051d20 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/i18n/fr.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_fr_hr_check_ssnid +# +# Translators: +# Quentin THEURET , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-10-21 08:47+0000\n" +"PO-Revision-Date: 2023-06-20 16:08+0000\n" +"Last-Translator: Alexis de Lattre \n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: l10n_fr_hr_check_ssnid +#: model:ir.model,name:l10n_fr_hr_check_ssnid.model_hr_employee +msgid "Employee" +msgstr "Employé" + +#. module: l10n_fr_hr_check_ssnid +#. odoo-python +#: code:addons/l10n_fr_hr_check_ssnid/models/hr_employee.py:0 +#, python-format +msgid "The French Social Security Number '%(ssnid)s' is invalid. (%(e)s)" +msgstr "" +"Le numéro de sécurité sociale français '%(ssnid)s' est invalide. (%(e)s)" diff --git a/l10n_fr_hr_check_ssnid/i18n/l10n_fr_hr_check_ssnid.pot b/l10n_fr_hr_check_ssnid/i18n/l10n_fr_hr_check_ssnid.pot new file mode 100644 index 000000000..3b5f689a4 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/i18n/l10n_fr_hr_check_ssnid.pot @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_fr_hr_check_ssnid +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_fr_hr_check_ssnid +#: model:ir.model,name:l10n_fr_hr_check_ssnid.model_hr_employee +msgid "Employee" +msgstr "" + +#. module: l10n_fr_hr_check_ssnid +#. odoo-python +#: code:addons/l10n_fr_hr_check_ssnid/models/hr_employee.py:0 +#, python-format +msgid "The French Social Security Number '%(ssnid)s' is invalid. (%(e)s)" +msgstr "" diff --git a/l10n_fr_hr_check_ssnid/models/__init__.py b/l10n_fr_hr_check_ssnid/models/__init__.py new file mode 100644 index 000000000..e11a62f98 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/models/__init__.py @@ -0,0 +1 @@ +from . import hr_employee diff --git a/l10n_fr_hr_check_ssnid/models/hr_employee.py b/l10n_fr_hr_check_ssnid/models/hr_employee.py new file mode 100644 index 000000000..1eb588c94 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/models/hr_employee.py @@ -0,0 +1,47 @@ +# Copyright 2018-2020 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging + +from odoo import _, api, models +from odoo.exceptions import ValidationError + +logger = logging.getLogger(__name__) + +try: + from stdnum.fr.nir import InvalidChecksum, InvalidFormat, InvalidLength, validate +except ImportError: + logger.debug("Cannot import stdnum") + + +class HrEmployee(models.Model): + _inherit = "hr.employee" + + @api.constrains("ssnid") + def _check_france_ssnid(self): + fr_country_codes = ( + "FR", + "GP", + "MQ", + "GF", + "RE", + "YT", + "PF", + "PM", + "MF", + "BL", + "NC", + ) + for empl in self: + if empl.company_id.country_id.code in fr_country_codes and empl.ssnid: + try: + validate(empl.ssnid) + except (InvalidFormat, InvalidLength, InvalidChecksum) as e: + raise ValidationError( + _( + "The French Social Security Number '%(ssnid)s' " + "is invalid. %(e)s" + ) + % {"ssnid": empl.ssnid, "e": e} + ) from e diff --git a/l10n_fr_hr_check_ssnid/pyproject.toml b/l10n_fr_hr_check_ssnid/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/l10n_fr_hr_check_ssnid/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_fr_hr_check_ssnid/readme/CONTRIBUTORS.md b/l10n_fr_hr_check_ssnid/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..b61afe5d0 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Alexis de Lattre \<\> diff --git a/l10n_fr_hr_check_ssnid/readme/DESCRIPTION.md b/l10n_fr_hr_check_ssnid/readme/DESCRIPTION.md new file mode 100644 index 000000000..b3de9d1b6 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +With this module, the social security number of employees of French +companies will be checked: if the length or checksum is wrong, an error +message will be displayed. diff --git a/l10n_fr_hr_check_ssnid/readme/INSTALL.md b/l10n_fr_hr_check_ssnid/readme/INSTALL.md new file mode 100644 index 000000000..fff240ea2 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/readme/INSTALL.md @@ -0,0 +1,7 @@ +This module require the Python +[stdnum](https://arthurdejong.org/python-stdnum/) library. To install +it, run: + +``` +pip3 install python-stdnum +``` diff --git a/l10n_fr_hr_check_ssnid/readme/USAGE.md b/l10n_fr_hr_check_ssnid/readme/USAGE.md new file mode 100644 index 000000000..71ab40830 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/readme/USAGE.md @@ -0,0 +1,4 @@ +Check that the country of the company is **France**. Go to the menu +*Employees \> Employees*, select an employee. In the tab *Private +Information*, enter the French social security number in the field *SSN +No*. diff --git a/l10n_fr_hr_check_ssnid/static/description/icon.png b/l10n_fr_hr_check_ssnid/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/l10n_fr_hr_check_ssnid/static/description/icon.png differ diff --git a/l10n_fr_hr_check_ssnid/static/description/index.html b/l10n_fr_hr_check_ssnid/static/description/index.html new file mode 100644 index 000000000..0d49b4fdb --- /dev/null +++ b/l10n_fr_hr_check_ssnid/static/description/index.html @@ -0,0 +1,445 @@ + + + + + +French Localization - Check Social Security Number + + + +
+

French Localization - Check Social Security Number

+ + +

Mature License: AGPL-3 OCA/l10n-france Translate me on Weblate Try me on Runboat

+

With this module, the social security number of employees of French +companies will be checked: if the length or checksum is wrong, an error +message will be displayed.

+

Table of contents

+ +
+

Installation

+

This module require the Python +stdnum library. To install +it, run:

+
+pip3 install python-stdnum
+
+
+
+

Usage

+

Check that the country of the company is France. Go to the menu +Employees > Employees, select an employee. In the tab Private +Information, enter the French social security number in the field SSN +No.

+
+
+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

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.

+

Current maintainer:

+

alexis-via

+

This module is part of the OCA/l10n-france project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_fr_hr_check_ssnid/tests/__init__.py b/l10n_fr_hr_check_ssnid/tests/__init__.py new file mode 100644 index 000000000..53639e4cf --- /dev/null +++ b/l10n_fr_hr_check_ssnid/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ssnid diff --git a/l10n_fr_hr_check_ssnid/tests/test_ssnid.py b/l10n_fr_hr_check_ssnid/tests/test_ssnid.py new file mode 100644 index 000000000..7f9408c96 --- /dev/null +++ b/l10n_fr_hr_check_ssnid/tests/test_ssnid.py @@ -0,0 +1,19 @@ +# Copyright 2018-2020 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase + + +class TestSsnidCheck(TransactionCase): + def test_validate_ssnid(self): + heo = self.env["hr.employee"] + # Set company to France + self.env.company.country_id = self.env.ref("base.fr").id + with self.assertRaises(ValidationError): + heo.create({"name": "AA", "ssnid": "1 91 12"}) + with self.assertRaises(ValidationError): + heo.create({"name": "AB", "ssnid": "1 91 02 99 412 042 19"}) + heo.create({"name": "AC", "ssnid": "1 91 02 99 412 042 42"}) + heo.create({"name": "AD", "ssnid": "1 55 01 2A 011 222 86"}) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..f8f07db71 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +python-stdnum