diff --git a/partner_identification_gln/README.rst b/partner_identification_gln/README.rst new file mode 100644 index 00000000000..85927ad26a3 --- /dev/null +++ b/partner_identification_gln/README.rst @@ -0,0 +1,99 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +========================== +Partner Identification GLN +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a59968939e1b8227c25a8cc6f99b7930f5c7bad4cee3eb0284b9e6ccf7586c8c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/19.0/partner_identification_gln + :alt: OCA/partner-contact +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/partner-contact-19-0/partner-contact-19-0-partner_identification_gln + :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/partner-contact&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon extends "Partner Identification Numbers" to provide a number +category for GLN registration + +see: http://www.gs1.org/1/glnrules/en/ + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module depends on 'stdnum' python module + +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 +------- + +* Acsone S.A. + +Contributors +------------ + +- Alvaro Estebanez +- Denis Roussel +- Meyomesse Gilles +- Bejaoui Souheil +- Simone Orsi +- Duong (Tran Quoc) +- Nils Coenen + +Other 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/partner-contact `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_identification_gln/__init__.py b/partner_identification_gln/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/partner_identification_gln/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_identification_gln/__manifest__.py b/partner_identification_gln/__manifest__.py new file mode 100644 index 00000000000..e7c07ca2aa9 --- /dev/null +++ b/partner_identification_gln/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2016-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Partner Identification GLN", + "summary": """ + This addon extends "Partner Identification Numbers" + to provide a number category for GLN registration""", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "author": "Acsone S.A.,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/partner-contact", + "depends": ["partner_identification"], + "data": ["data/partner_identification_gln.xml"], + "external_dependencies": {"python": ["python-stdnum"]}, + "installable": True, +} diff --git a/partner_identification_gln/data/partner_identification_gln.xml b/partner_identification_gln/data/partner_identification_gln.xml new file mode 100644 index 00000000000..5704b717f6d --- /dev/null +++ b/partner_identification_gln/data/partner_identification_gln.xml @@ -0,0 +1,24 @@ + + + + GLN Identification Number + gln_id_number + + + + GCP Identification Number + gcp_id_number + + + diff --git a/partner_identification_gln/i18n/es.po b/partner_identification_gln/i18n/es.po new file mode 100644 index 00000000000..1eebd4cbf3e --- /dev/null +++ b/partner_identification_gln/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification_gln +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-03 21:36+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: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gcp_number_category +msgid "GCP Identification Number" +msgstr "Número de Identificación GCP" + +#. module: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gln_number_category +msgid "GLN Identification Number" +msgstr "Número de Identificación GLN" + +#. module: partner_identification_gln +#: model:ir.model,name:partner_identification_gln.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "Categoría ID de socio" diff --git a/partner_identification_gln/i18n/it.po b/partner_identification_gln/i18n/it.po new file mode 100644 index 00000000000..f49258bfd70 --- /dev/null +++ b/partner_identification_gln/i18n/it.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification_gln +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-07-22 07:58+0000\n" +"Last-Translator: mymage \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 5.6.2\n" + +#. module: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gcp_number_category +msgid "GCP Identification Number" +msgstr "Numeri di identificazione GCP" + +#. module: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gln_number_category +msgid "GLN Identification Number" +msgstr "Numero di identificazione GLN" + +#. module: partner_identification_gln +#: model:ir.model,name:partner_identification_gln.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "ID categoria partner" diff --git a/partner_identification_gln/i18n/partner_identification_gln.pot b/partner_identification_gln/i18n/partner_identification_gln.pot new file mode 100644 index 00000000000..e0ae6284637 --- /dev/null +++ b/partner_identification_gln/i18n/partner_identification_gln.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification_gln +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gcp_number_category +msgid "GCP Identification Number" +msgstr "" + +#. module: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gln_number_category +msgid "GLN Identification Number" +msgstr "" + +#. module: partner_identification_gln +#: model:ir.model,name:partner_identification_gln.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "" diff --git a/partner_identification_gln/i18n/sl.po b/partner_identification_gln/i18n/sl.po new file mode 100644 index 00000000000..30c36c74f8b --- /dev/null +++ b/partner_identification_gln/i18n/sl.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification_gln +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-09-11 11:05+0000\n" +"PO-Revision-Date: 2019-09-11 11:05+0000\n" +"Last-Translator: Matjaž Mozetič , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3);\n" + +#. module: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gcp_number_category +msgid "GCP Identification Number" +msgstr "GCP identifikacijska številka" + +#. module: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gln_number_category +msgid "GLN Identification Number" +msgstr "GLN identifikacijska številka" + +#. module: partner_identification_gln +#: model:ir.model,name:partner_identification_gln.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "Partnerjeve ID kategorije" diff --git a/partner_identification_gln/models/__init__.py b/partner_identification_gln/models/__init__.py new file mode 100644 index 00000000000..3ca19e1aed9 --- /dev/null +++ b/partner_identification_gln/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner_id_category diff --git a/partner_identification_gln/models/res_partner_id_category.py b/partner_identification_gln/models/res_partner_id_category.py new file mode 100644 index 00000000000..a2c85727edf --- /dev/null +++ b/partner_identification_gln/models/res_partner_id_category.py @@ -0,0 +1,48 @@ +# Copyright 2016-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from stdnum import ean +from stdnum.exceptions import InvalidChecksum, InvalidFormat, InvalidLength + +from odoo import models + + +class ResPartnerIdCategory(models.Model): + _inherit = "res.partner.id_category" + + def validate_res_partner_gln(self, id_number): + self.ensure_one() + if not id_number: + return False + try: + ean.validate(id_number.name) + except (InvalidChecksum, InvalidFormat, InvalidLength): + return True + + cat = self.env.ref( + "partner_identification_gln.partner_identification_gln_number_category" + ).id + duplicate_gln = self._search_duplicate(cat, id_number, True) + + if duplicate_gln: + return True + + return False + + def validate_res_partner_gcp(self, id_number): + self.ensure_one() + if not id_number: + return False + + if len(id_number.name) < 1 or len(id_number.name) > 12: + return True + + cat = self.env.ref( + "partner_identification_gln.partner_identification_gcp_number_category" + ).id + duplicate_gln = self._search_duplicate(cat, id_number) + + if duplicate_gln: + return True + + return False diff --git a/partner_identification_gln/pyproject.toml b/partner_identification_gln/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/partner_identification_gln/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/partner_identification_gln/readme/CONTRIBUTORS.md b/partner_identification_gln/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..dcb0769a1e4 --- /dev/null +++ b/partner_identification_gln/readme/CONTRIBUTORS.md @@ -0,0 +1,7 @@ +- Alvaro Estebanez \<\> +- Denis Roussel \<\> +- Meyomesse Gilles \<\> +- Bejaoui Souheil \<\> +- Simone Orsi \<\> +- Duong (Tran Quoc) \<\> +- Nils Coenen \<\> diff --git a/partner_identification_gln/readme/CREDITS.md b/partner_identification_gln/readme/CREDITS.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/partner_identification_gln/readme/DESCRIPTION.md b/partner_identification_gln/readme/DESCRIPTION.md new file mode 100644 index 00000000000..3ad2813b287 --- /dev/null +++ b/partner_identification_gln/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This addon extends "Partner Identification Numbers" to provide a number +category for GLN registration + +see: diff --git a/partner_identification_gln/readme/INSTALL.md b/partner_identification_gln/readme/INSTALL.md new file mode 100644 index 00000000000..ecf4e9c161b --- /dev/null +++ b/partner_identification_gln/readme/INSTALL.md @@ -0,0 +1 @@ +This module depends on 'stdnum' python module diff --git a/partner_identification_gln/static/description/icon.svg b/partner_identification_gln/static/description/icon.svg new file mode 100644 index 00000000000..22ee0315097 --- /dev/null +++ b/partner_identification_gln/static/description/icon.svg @@ -0,0 +1,78 @@ + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/partner_identification_gln/static/description/index.html b/partner_identification_gln/static/description/index.html new file mode 100644 index 00000000000..7b9dfca3515 --- /dev/null +++ b/partner_identification_gln/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Partner Identification GLN

+ +

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runboat

+

This addon extends “Partner Identification Numbers” to provide a number +category for GLN registration

+

see: http://www.gs1.org/1/glnrules/en/

+

Table of contents

+ +
+

Installation

+

This module depends on ‘stdnum’ python module

+
+
+

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

+
    +
  • Acsone S.A.
  • +
+
+
+

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.

+

This module is part of the OCA/partner-contact project on GitHub.

+

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

+
+
+
+
+ + diff --git a/partner_identification_gln/tests/__init__.py b/partner_identification_gln/tests/__init__.py new file mode 100644 index 00000000000..bd636d043e2 --- /dev/null +++ b/partner_identification_gln/tests/__init__.py @@ -0,0 +1 @@ +from . import test_gln diff --git a/partner_identification_gln/tests/test_gln.py b/partner_identification_gln/tests/test_gln.py new file mode 100644 index 00000000000..bbc9721a27d --- /dev/null +++ b/partner_identification_gln/tests/test_gln.py @@ -0,0 +1,78 @@ +# Copyright 2016 Acsone S.A. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.exceptions import ValidationError +from odoo.fields import Command +from odoo.tests.common import TransactionCase + + +class TestGLN(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.partner = cls.env["res.partner"].create({"name": "TestGLN"}) + cls.partner2 = cls.env["res.partner"].create({"name": "TestGLN2"}) + pc = cls.env.ref( + "partner_identification_gln.partner_identification_gln_number_category" + ) + cls.partner_id_category = pc + + pc_gcp = cls.env.ref( + "partner_identification_gln.partner_identification_gcp_number_category" + ) + cls.partner_id_gcp_category = pc_gcp + + def test_gln(self): + # Good GLN + vals = {"name": "5450534005852", "category_id": self.partner_id_category.id} + + self.partner.write({"id_numbers": [Command.create(vals)]}) + id_number = self.partner.id_numbers[0] + + self.assertEqual(id_number.name, "5450534005852") + + # Duplicate GLN + vals = {"name": "5450534005852", "category_id": self.partner_id_category.id} + + with self.assertRaises(ValidationError): + self.partner2.write({"id_numbers": [Command.create(vals)]}) + + # Bad GLN + vals = {"name": "5450534001716", "category_id": self.partner_id_category.id} + with self.assertRaises(ValidationError): + self.partner.write({"id_numbers": [Command.create(vals)]}) + + def test_gln_with_no_number(self): + self.assertFalse( + self.partner_id_category.validate_res_partner_gln(id_number=None) + ) + + def test_gcp(self): + # Good GLN + vals = {"name": "545053", "category_id": self.partner_id_gcp_category.id} + self.partner.write({"id_numbers": [Command.create(vals)]}) + id_number = self.partner.id_numbers[0] + + self.assertEqual(id_number.name, "545053") + + # Duplicate GLN + vals = {"name": "545053", "category_id": self.partner_id_gcp_category.id} + + with self.assertRaises(ValidationError): + self.partner2.write({"id_numbers": [Command.create(vals)]}) + + # Bad GLN + vals = {"name": "5450534001716", "category_id": self.partner_id_gcp_category.id} + with self.assertRaises(ValidationError): + self.partner.write({"id_numbers": [Command.create(vals)]}) + + def test_gcp_with_no_number(self): + self.assertFalse( + self.partner_id_gcp_category.validate_res_partner_gln(id_number=None) + ) + + def test_validate_res_partner_gcp_return_false(self): + self.assertFalse( + self.partner_id_category.validate_res_partner_gcp(id_number=None) + ) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000000..f8f07db71f9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +python-stdnum diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000000..f625338af56 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-partner_identification @ git+https://github.com/OCA/partner-contact.git@refs/pull/2206/head#subdirectory=partner_identification