diff --git a/l10n_nl_oin/README.rst b/l10n_nl_oin/README.rst new file mode 100644 index 000000000..7c94d0fd5 --- /dev/null +++ b/l10n_nl_oin/README.rst @@ -0,0 +1,100 @@ +===================================== +Organisatie-identificatienummer (OIN) +===================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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--netherlands-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-netherlands/tree/14.0/l10n_nl_oin + :alt: OCA/l10n-netherlands +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-netherlands-14-0/l10n-netherlands-14-0-l10n_nl_oin + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/176/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module validates the Dutch `Organisatie-identificatienummer (OIN)` field +on partner forms. + +The field is visible when the field ``company_type`` is set to ``Company`` +and when the Country is ``The Netherlands``. + +A double check on the OIN is done when inserting/modifying its value: + +- validation of the OIN (check whether the format is correct); +- check if another partner with the same OIN already exists. + +In both cases, a non-blocking alert is shown. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +* Open a form of a contact: flag Company must be checked (flag "Individual" must be unchecked) +* Enter the OIN number + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Onestein + +Contributors +~~~~~~~~~~~~ + +* Andrea Stirpe + +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-astirpe| image:: https://github.com/astirpe.png?size=40px + :target: https://github.com/astirpe + :alt: astirpe + +Current `maintainer `__: + +|maintainer-astirpe| + +This module is part of the `OCA/l10n-netherlands `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_nl_oin/__init__.py b/l10n_nl_oin/__init__.py new file mode 100644 index 000000000..31660d6a9 --- /dev/null +++ b/l10n_nl_oin/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/l10n_nl_oin/__manifest__.py b/l10n_nl_oin/__manifest__.py new file mode 100644 index 000000000..c6507e882 --- /dev/null +++ b/l10n_nl_oin/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2020 Onestein () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Organisatie-identificatienummer (OIN)", + "version": "16.0.1.0.0", + "category": "Dutch Localization", + "license": "AGPL-3", + "summary": "Adds Dutch OIN field", + "author": "Onestein, Odoo Community Association (OCA)", + "maintainers": ["astirpe"], + "website": "https://github.com/OCA/l10n-netherlands", + "depends": ["l10n_nl"], + "installable": True, +} diff --git a/l10n_nl_oin/i18n/l10n_nl_oin.pot b/l10n_nl_oin/i18n/l10n_nl_oin.pot new file mode 100644 index 000000000..a82541eb6 --- /dev/null +++ b/l10n_nl_oin/i18n/l10n_nl_oin.pot @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_nl_oin +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "Another partner (%s) has the same OIN (%s)." +msgstr "" + +#. module: l10n_nl_oin +#: model:ir.model,name:l10n_nl_oin.model_res_partner +msgid "Contact" +msgstr "" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__display_name +msgid "Display Name" +msgstr "" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_users__nl_oin +msgid "Dutch OIN" +msgstr "" + +#. module: l10n_nl_oin +#: model:ir.model.fields,help:l10n_nl_oin.field_res_partner__nl_oin +#: model:ir.model.fields,help:l10n_nl_oin.field_res_users__nl_oin +msgid "Dutch Organisatie-identificatienummer (OIN)" +msgstr "" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__id +msgid "ID" +msgstr "" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner____last_update +msgid "Last Modified on" +msgstr "" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__nl_oin_display +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_users__nl_oin_display +msgid "Nl Oin Display" +msgstr "" + +#. module: l10n_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "The OIN you entered (%s) is not valid." +msgstr "" + +#. module: l10n_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "Warning!" +msgstr "" diff --git a/l10n_nl_oin/i18n/nl.po b/l10n_nl_oin/i18n/nl.po new file mode 100644 index 000000000..cad3aa4c2 --- /dev/null +++ b/l10n_nl_oin/i18n/nl.po @@ -0,0 +1,74 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_nl_oin +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-03-03 09:45+0000\n" +"Last-Translator: Cas Vissers \n" +"Language-Team: none\n" +"Language: nl\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.3.2\n" + +#. module: l10n_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "Another partner (%s) has the same OIN (%s)." +msgstr "Een andere relatie (%s) heeft dezelfde OIN (%s)." + +#. module: l10n_nl_oin +#: model:ir.model,name:l10n_nl_oin.model_res_partner +msgid "Contact" +msgstr "Contact" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__display_name +msgid "Display Name" +msgstr "Weergave naam" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_users__nl_oin +msgid "Dutch OIN" +msgstr "Nederlands OIN" + +#. module: l10n_nl_oin +#: model:ir.model.fields,help:l10n_nl_oin.field_res_partner__nl_oin +#: model:ir.model.fields,help:l10n_nl_oin.field_res_users__nl_oin +msgid "Dutch Organisatie-identificatienummer (OIN)" +msgstr "Nederlands Organisatie Identificatie Nummer (OIN)" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__id +msgid "ID" +msgstr "ID" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner____last_update +msgid "Last Modified on" +msgstr "Laatst gewijzigd op" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__nl_oin_display +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_users__nl_oin_display +msgid "Nl Oin Display" +msgstr "Nl OIN weergave" + +#. module: l10n_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "The OIN you entered (%s) is not valid." +msgstr "De ingevoerde OIN (%s) is ongeldig." + +#. module: l10n_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "Warning!" +msgstr "Let op!" diff --git a/l10n_nl_oin/i18n/nl_NL.po b/l10n_nl_oin/i18n/nl_NL.po new file mode 100644 index 000000000..040686f07 --- /dev/null +++ b/l10n_nl_oin/i18n/nl_NL.po @@ -0,0 +1,74 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_nl_oin +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-03-03 09:45+0000\n" +"Last-Translator: Cas Vissers \n" +"Language-Team: none\n" +"Language: nl_NL\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.3.2\n" + +#. module: l10n_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "Another partner (%s) has the same OIN (%s)." +msgstr "Een andere relatie (%s) heeft dezelfde OIN (%s)." + +#. module: l10n_nl_oin +#: model:ir.model,name:l10n_nl_oin.model_res_partner +msgid "Contact" +msgstr "Contact" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__display_name +msgid "Display Name" +msgstr "Weergave naam" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_users__nl_oin +msgid "Dutch OIN" +msgstr "Nederlands OIN" + +#. module: l10n_nl_oin +#: model:ir.model.fields,help:l10n_nl_oin.field_res_partner__nl_oin +#: model:ir.model.fields,help:l10n_nl_oin.field_res_users__nl_oin +msgid "Dutch Organisatie-identificatienummer (OIN)" +msgstr "Nederlands Organisatie Identificatie Nummer (OIN)" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__id +msgid "ID" +msgstr "ID" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner____last_update +msgid "Last Modified on" +msgstr "Laatst gewijzigd op" + +#. module: l10n_nl_oin +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_partner__nl_oin_display +#: model:ir.model.fields,field_description:l10n_nl_oin.field_res_users__nl_oin_display +msgid "Nl Oin Display" +msgstr "Nl OIN weergave" + +#. module: l10n_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "The OIN you entered (%s) is not valid." +msgstr "De ingevoerde OIN (%s) is ongeldig." + +#. module: l10n_nl_oin +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#: code:addons/l10n_nl_oin/models/res_partner.py:0 +#, python-format +msgid "Warning!" +msgstr "Let op!" diff --git a/l10n_nl_oin/models/__init__.py b/l10n_nl_oin/models/__init__.py new file mode 100644 index 000000000..c6cc3b329 --- /dev/null +++ b/l10n_nl_oin/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import res_partner diff --git a/l10n_nl_oin/models/res_partner.py b/l10n_nl_oin/models/res_partner.py new file mode 100644 index 000000000..c5f2e34e4 --- /dev/null +++ b/l10n_nl_oin/models/res_partner.py @@ -0,0 +1,52 @@ +# Copyright 2020 Onestein () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + l10n_nl_oin = fields.Char( + copy=False, help="Dutch Organisatie-identificatienummer (OIN)" + ) + + @api.onchange("l10n_nl_oin") + def onchange_nl_oin(self): + warning = {} + if self.l10n_nl_oin: + # check is valid, otherwise display a warning + warning = self._warn_oin_invalid() + + # search for another partner with the same OIN + args = [("l10n_nl_oin", "=", self.l10n_nl_oin), ("name", "!=", self.name)] + + # refine search in case of multicompany setting + if self.company_id: + args += [("company_id", "=", self.company_id.id)] + other_partner = self.search(args, limit=1) + + # if another partner exists, display a warning + if other_partner: + warning = other_partner._warn_oin_existing() + return {"warning": warning} + + def _warn_oin_invalid(self): + self.ensure_one() + warning = {} + if len(self.l10n_nl_oin) != 20 or not self.l10n_nl_oin.isdigit(): + msg = _("The OIN you entered (%(oin)s) is not valid.") + warning = { + "title": _("Warning!"), + "message": msg % {"oin": self.l10n_nl_oin}, + } + return warning + + def _warn_oin_existing(self): + self.ensure_one() + msg = _("Another partner (%(name)s) has the same OIN (%(oin)s).") + warning = { + "title": _("Warning!"), + "message": msg % {"name": self.name, "oin": self.l10n_nl_oin}, + } + return warning diff --git a/l10n_nl_oin/readme/CONTRIBUTORS.rst b/l10n_nl_oin/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..4518218c8 --- /dev/null +++ b/l10n_nl_oin/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Andrea Stirpe diff --git a/l10n_nl_oin/readme/DESCRIPTION.rst b/l10n_nl_oin/readme/DESCRIPTION.rst new file mode 100644 index 000000000..109b472ab --- /dev/null +++ b/l10n_nl_oin/readme/DESCRIPTION.rst @@ -0,0 +1,12 @@ +This module validates the Dutch `Organisatie-identificatienummer (OIN)` field +on partner forms. + +The field is visible when the field ``company_type`` is set to ``Company`` +and when the Country is ``The Netherlands``. + +A double check on the OIN is done when inserting/modifying its value: + +- validation of the OIN (check whether the format is correct); +- check if another partner with the same OIN already exists. + +In both cases, a non-blocking alert is shown. diff --git a/l10n_nl_oin/readme/USAGE.rst b/l10n_nl_oin/readme/USAGE.rst new file mode 100644 index 000000000..2ee26a2e0 --- /dev/null +++ b/l10n_nl_oin/readme/USAGE.rst @@ -0,0 +1,4 @@ +To use this module, you need to: + +* Open a form of a contact: flag Company must be checked (flag "Individual" must be unchecked) +* Enter the OIN number diff --git a/l10n_nl_oin/static/description/icon.png b/l10n_nl_oin/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/l10n_nl_oin/static/description/icon.png differ diff --git a/l10n_nl_oin/static/description/index.html b/l10n_nl_oin/static/description/index.html new file mode 100644 index 000000000..c83181ad1 --- /dev/null +++ b/l10n_nl_oin/static/description/index.html @@ -0,0 +1,438 @@ + + + + + + +Organisatie-identificatienummer (OIN) + + + +
+

Organisatie-identificatienummer (OIN)

+ + +

Beta License: AGPL-3 OCA/l10n-netherlands Translate me on Weblate Try me on Runbot

+

This module adds the Dutch Organisatie-identificatienummer (OIN) field +on partner forms.

+

The field is visible when the field company_type is set to Company.

+

A double check on the OIN is done when inserting/modifying its value:

+
    +
  • validation of the OIN (check whether the format is correct);
  • +
  • check if another partner with the same OIN already exists.
  • +
+

In both cases, a non-blocking alert is shown.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  • Open a form of a contact: flag Company must be checked (flag “Individual” must be unchecked)
  • +
  • Enter the OIN number
  • +
+
+
+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Onestein
  • +
+
+
+

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:

+

astirpe

+

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

+

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

+
+
+
+ + diff --git a/l10n_nl_oin/tests/__init__.py b/l10n_nl_oin/tests/__init__.py new file mode 100644 index 000000000..6ba602615 --- /dev/null +++ b/l10n_nl_oin/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_l10n_nl_oin diff --git a/l10n_nl_oin/tests/test_l10n_nl_oin.py b/l10n_nl_oin/tests/test_l10n_nl_oin.py new file mode 100644 index 000000000..ee1aaab45 --- /dev/null +++ b/l10n_nl_oin/tests/test_l10n_nl_oin.py @@ -0,0 +1,64 @@ +# Copyright 2020 Onestein () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestOin(TransactionCase): + def setUp(self): + super().setUp() + + self.partner_oin = self.env["res.partner"].create( + { + "name": "Partner with OIN", + "company_id": self.env.company.id, + "country_id": self.env.ref("base.nl").id, + "company_type": "company", + } + ) + + def test_01_oin_not_valid(self): + self.partner_oin.l10n_nl_oin = "123" + res = self.partner_oin.onchange_nl_oin() + self.assertEqual(self.partner_oin.l10n_nl_oin, "123") + warning = res.get("warning") + self.assertTrue(warning) + message = warning.get("message") + self.assertTrue(message) + msg_txt = "The OIN you entered (123) is not valid." + self.assertEqual(message, msg_txt) + title = warning.get("title") + self.assertTrue(title) + self.assertEqual(title, "Warning!") + + def test_02_oin_valid(self): + self.partner_oin.l10n_nl_oin = "12345678901234567890" + res = self.partner_oin.onchange_nl_oin() + self.assertEqual(self.partner_oin.l10n_nl_oin, "12345678901234567890") + warning = res.get("warning") + self.assertFalse(warning) + + def test_03_oin_another_partner(self): + new_partner_oin = self.env["res.partner"].create( + { + "name": "Partner with OIN - NEW", + "l10n_nl_oin": "12345678901234567890", + "company_id": self.env.company.id, + } + ) + self.partner_oin.l10n_nl_oin = "12345678901234567890" + res = self.partner_oin.onchange_nl_oin() + self.assertTrue(res.get("warning")) + warning = new_partner_oin._warn_oin_existing() + message = warning.get("message") + self.assertTrue(message) + msg_txt = ( + "Another partner (Partner with OIN - NEW) has the same OIN " + "(12345678901234567890)." + ) + self.assertEqual(message, msg_txt) + self.assertEqual(message, res["warning"]["message"]) + title = warning.get("title") + self.assertTrue(title) + self.assertEqual(title, "Warning!") + self.assertEqual(title, res["warning"]["title"]) diff --git a/setup/l10n_nl_oin/odoo/addons/l10n_nl_oin b/setup/l10n_nl_oin/odoo/addons/l10n_nl_oin new file mode 120000 index 000000000..5bdc7d6a2 --- /dev/null +++ b/setup/l10n_nl_oin/odoo/addons/l10n_nl_oin @@ -0,0 +1 @@ +../../../../l10n_nl_oin \ No newline at end of file diff --git a/setup/l10n_nl_oin/setup.py b/setup/l10n_nl_oin/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/l10n_nl_oin/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)