diff --git a/partner_vat_unique/README.rst b/partner_vat_unique/README.rst new file mode 100644 index 000000000..29e5a4bc6 --- /dev/null +++ b/partner_vat_unique/README.rst @@ -0,0 +1,94 @@ +================== +Partner VAT Unique +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/14.0/partner_vat_unique + :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-14-0/partner-contact-14-0-partner_vat_unique + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Module to make the VAT number unique for customers and suppliers. Will not +consider empty VATs as duplicated. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +Will not check previous VAT duplicates, so it is recomended make sure there +isn't any duplicated VAT before installation. + +Known issues / Roadmap +====================== + +* Creation of the partner from XML-RPC. +* Partner creation by importing a CSV file, in those cases you miss the notice. + +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 +~~~~~~~ + +* Grant Thornton S.L.P + +Contributors +~~~~~~~~~~~~ + +* Ismael Calvo +* Michael Michot +* Koen Loodts + +* `Tecnativa `__: + * Vicent Cubells + * Manuel Calero - Tecnativa + +* Tharathip Chaweewongphan + +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_vat_unique/__init__.py b/partner_vat_unique/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/partner_vat_unique/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_vat_unique/__manifest__.py b/partner_vat_unique/__manifest__.py new file mode 100644 index 000000000..e72766729 --- /dev/null +++ b/partner_vat_unique/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2017 Grant Thornton Spain - Ismael Calvo +# Copyright 2020 Manuel Calero - Tecnativa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Partner VAT Unique", + "summary": "Module to make the VAT number unique for customers and suppliers.", + "version": "14.0.1.0.0", + "category": "Customer Relationship Management", + "website": "https://github.com/OCA/partner-contact", + "author": "Grant Thornton S.L.P, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": True, + "installable": True, + "depends": ["base"], +} diff --git a/partner_vat_unique/i18n/es.po b/partner_vat_unique/i18n/es.po new file mode 100644 index 000000000..c389170e2 --- /dev/null +++ b/partner_vat_unique/i18n/es.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_vat_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-29 11:43+0000\n" +"PO-Revision-Date: 2019-03-01 14:52+0000\n" +"Last-Translator: Marta Vázquez Rodríguez \n" +"Language-Team: \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 3.4\n" + +#. module: partner_vat_unique +#: model:ir.model,name:partner_vat_unique.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: partner_vat_unique +#: model:ir.model.fields,field_description:partner_vat_unique.field_res_partner__vat +#: model:ir.model.fields,field_description:partner_vat_unique.field_res_users__vat +msgid "Tax ID" +msgstr "Tax" + +#. module: partner_vat_unique +#: model:ir.model.fields,help:partner_vat_unique.field_res_partner__vat +#: model:ir.model.fields,help:partner_vat_unique.field_res_users__vat +msgid "" +"The Tax Identification Number. Complete it if the contact is subjected to " +"government taxes. Used in some legal statements." +msgstr "" +"Complete el número de identificación fiscal si el contacto está sujeto a " +"impuestos gubernamentales. Utilizado en algunas declaraciones legales" + +#. module: partner_vat_unique +#: code:addons/partner_vat_unique/models/res_partner.py:0 +#, python-format +msgid "The VAT %s already exists in another partner." +msgstr "El NIF %s debe de ser único por empresa." + +#~ msgid "Partner" +#~ msgstr "Empresa" diff --git a/partner_vat_unique/i18n/it.po b/partner_vat_unique/i18n/it.po new file mode 100644 index 000000000..58c38e697 --- /dev/null +++ b/partner_vat_unique/i18n/it.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_vat_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-08-09 19:44+0000\n" +"Last-Translator: Marco Calcagni \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 3.7.1\n" + +#. module: partner_vat_unique +#: model:ir.model,name:partner_vat_unique.model_res_partner +msgid "Contact" +msgstr "Contatto" + +#. module: partner_vat_unique +#: model:ir.model.fields,field_description:partner_vat_unique.field_res_partner__vat +#: model:ir.model.fields,field_description:partner_vat_unique.field_res_users__vat +msgid "Tax ID" +msgstr "" + +#. module: partner_vat_unique +#: model:ir.model.fields,help:partner_vat_unique.field_res_partner__vat +#: model:ir.model.fields,help:partner_vat_unique.field_res_users__vat +msgid "" +"The Tax Identification Number. Complete it if the contact is subjected to " +"government taxes. Used in some legal statements." +msgstr "" + +#. module: partner_vat_unique +#: code:addons/partner_vat_unique/models/res_partner.py:0 +#, python-format +msgid "The VAT %s already exists in another partner." +msgstr "La Partita Iva %s è già assegnata ad un altro partner." diff --git a/partner_vat_unique/i18n/partner_vat_unique.pot b/partner_vat_unique/i18n/partner_vat_unique.pot new file mode 100644 index 000000000..faec32fec --- /dev/null +++ b/partner_vat_unique/i18n/partner_vat_unique.pot @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_vat_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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_vat_unique +#: model:ir.model,name:partner_vat_unique.model_res_partner +msgid "Contact" +msgstr "" + +#. module: partner_vat_unique +#: model:ir.model.fields,field_description:partner_vat_unique.field_res_partner__vat +#: model:ir.model.fields,field_description:partner_vat_unique.field_res_users__vat +msgid "Tax ID" +msgstr "" + +#. module: partner_vat_unique +#: model:ir.model.fields,help:partner_vat_unique.field_res_partner__vat +#: model:ir.model.fields,help:partner_vat_unique.field_res_users__vat +msgid "" +"The Tax Identification Number. Complete it if the contact is subjected to " +"government taxes. Used in some legal statements." +msgstr "" + +#. module: partner_vat_unique +#: code:addons/partner_vat_unique/models/res_partner.py:0 +#, python-format +msgid "The VAT %s already exists in another partner." +msgstr "" diff --git a/partner_vat_unique/i18n/pt.po b/partner_vat_unique/i18n/pt.po new file mode 100644 index 000000000..7b66d9b05 --- /dev/null +++ b/partner_vat_unique/i18n/pt.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_vat_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-08-12 13:44+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\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 3.7.1\n" + +#. module: partner_vat_unique +#: model:ir.model,name:partner_vat_unique.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: partner_vat_unique +#: model:ir.model.fields,field_description:partner_vat_unique.field_res_partner__vat +#: model:ir.model.fields,field_description:partner_vat_unique.field_res_users__vat +msgid "Tax ID" +msgstr "" + +#. module: partner_vat_unique +#: model:ir.model.fields,help:partner_vat_unique.field_res_partner__vat +#: model:ir.model.fields,help:partner_vat_unique.field_res_users__vat +msgid "" +"The Tax Identification Number. Complete it if the contact is subjected to " +"government taxes. Used in some legal statements." +msgstr "" + +#. module: partner_vat_unique +#: code:addons/partner_vat_unique/models/res_partner.py:0 +#, python-format +msgid "The VAT %s already exists in another partner." +msgstr "O NIF %s já existe noutro parceiro." diff --git a/partner_vat_unique/models/__init__.py b/partner_vat_unique/models/__init__.py new file mode 100644 index 000000000..91fed54d4 --- /dev/null +++ b/partner_vat_unique/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/partner_vat_unique/models/res_partner.py b/partner_vat_unique/models/res_partner.py new file mode 100644 index 000000000..88944f1d2 --- /dev/null +++ b/partner_vat_unique/models/res_partner.py @@ -0,0 +1,28 @@ +# Copyright 2017 Grant Thornton Spain - Ismael Calvo +# Copyright 2020 Manuel Calero - Tecnativa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError +from odoo.tools import config + + +class ResPartner(models.Model): + _inherit = "res.partner" + + vat = fields.Char(copy=False) + + @api.constrains("vat") + def _check_vat_unique(self): + for record in self: + if record.parent_id or not record.vat: + continue + test_condition = config["test_enable"] and not self.env.context.get( + "test_vat" + ) + if test_condition: + continue + if record.same_vat_partner_id: + raise ValidationError( + _("The VAT %s already exists in another partner.") % record.vat + ) diff --git a/partner_vat_unique/readme/CONTRIBUTORS.rst b/partner_vat_unique/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..3b84aa2c1 --- /dev/null +++ b/partner_vat_unique/readme/CONTRIBUTORS.rst @@ -0,0 +1,9 @@ +* Ismael Calvo +* Michael Michot +* Koen Loodts + +* `Tecnativa `__: + * Vicent Cubells + * Manuel Calero - Tecnativa + +* Tharathip Chaweewongphan diff --git a/partner_vat_unique/readme/DESCRIPTION.rst b/partner_vat_unique/readme/DESCRIPTION.rst new file mode 100644 index 000000000..e463f5434 --- /dev/null +++ b/partner_vat_unique/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Module to make the VAT number unique for customers and suppliers. Will not +consider empty VATs as duplicated. diff --git a/partner_vat_unique/readme/INSTALL.rst b/partner_vat_unique/readme/INSTALL.rst new file mode 100644 index 000000000..10422fe3d --- /dev/null +++ b/partner_vat_unique/readme/INSTALL.rst @@ -0,0 +1,2 @@ +Will not check previous VAT duplicates, so it is recomended make sure there +isn't any duplicated VAT before installation. diff --git a/partner_vat_unique/readme/ROADMAP.rst b/partner_vat_unique/readme/ROADMAP.rst new file mode 100644 index 000000000..606c4f0b0 --- /dev/null +++ b/partner_vat_unique/readme/ROADMAP.rst @@ -0,0 +1,2 @@ +* Creation of the partner from XML-RPC. +* Partner creation by importing a CSV file, in those cases you miss the notice. diff --git a/partner_vat_unique/static/description/icon.png b/partner_vat_unique/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/partner_vat_unique/static/description/icon.png differ diff --git a/partner_vat_unique/static/description/index.html b/partner_vat_unique/static/description/index.html new file mode 100644 index 000000000..75719e788 --- /dev/null +++ b/partner_vat_unique/static/description/index.html @@ -0,0 +1,446 @@ + + + + + + +Partner VAT Unique + + + +
+

Partner VAT Unique

+ + +

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

+

Module to make the VAT number unique for customers and suppliers. Will not +consider empty VATs as duplicated.

+

Table of contents

+ +
+

Installation

+

Will not check previous VAT duplicates, so it is recomended make sure there +isn’t any duplicated VAT before installation.

+
+
+

Known issues / Roadmap

+
    +
  • Creation of the partner from XML-RPC.
  • +
  • Partner creation by importing a CSV file, in those cases you miss the notice.
  • +
+
+
+

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

+
    +
  • Grant Thornton S.L.P
  • +
+
+
+

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_vat_unique/tests/__init__.py b/partner_vat_unique/tests/__init__.py new file mode 100644 index 000000000..0742f6bf1 --- /dev/null +++ b/partner_vat_unique/tests/__init__.py @@ -0,0 +1 @@ +from . import test_vat_unique diff --git a/partner_vat_unique/tests/test_vat_unique.py b/partner_vat_unique/tests/test_vat_unique.py new file mode 100644 index 000000000..94a67d095 --- /dev/null +++ b/partner_vat_unique/tests/test_vat_unique.py @@ -0,0 +1,25 @@ +# Copyright 2017 Grant Thornton Spain - Ismael Calvo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.exceptions import ValidationError +from odoo.tests.common import SavepointCase + + +class TestVatUnique(SavepointCase): + @classmethod + def setUpClass(cls): + super(TestVatUnique, cls).setUpClass() + cls.partner_model = cls.env["res.partner"] + cls.partner = cls.partner_model.create( + {"name": "Test partner", "vat": "ESA12345674"} + ) + + def test_duplicated_vat_creation(self): + with self.assertRaises(ValidationError): + self.partner_model.with_context(test_vat=True).create( + {"name": "Second partner", "vat": "ESA12345674"} + ) + + def test_duplicate_partner(self): + partner_copied = self.partner.copy() + self.assertFalse(partner_copied.vat) diff --git a/setup/partner_vat_unique/odoo/addons/partner_vat_unique b/setup/partner_vat_unique/odoo/addons/partner_vat_unique new file mode 120000 index 000000000..236d815f0 --- /dev/null +++ b/setup/partner_vat_unique/odoo/addons/partner_vat_unique @@ -0,0 +1 @@ +../../../../partner_vat_unique \ No newline at end of file diff --git a/setup/partner_vat_unique/setup.py b/setup/partner_vat_unique/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_vat_unique/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)