Browse Source

Merge pull request #616 from michotm/11.0-mig-partner_vat_unique

11.0 mig partner vat unique
pull/618/head
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
0e18ce2f30
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 60
      partner_vat_unique/README.rst
  2. 1
      partner_vat_unique/__init__.py
  3. 13
      partner_vat_unique/__manifest__.py
  4. 28
      partner_vat_unique/i18n/es.po
  5. 26
      partner_vat_unique/i18n/partner_vat_unique.pot
  6. 1
      partner_vat_unique/models/__init__.py
  7. 29
      partner_vat_unique/models/res_partner.py
  8. BIN
      partner_vat_unique/static/description/icon.png
  9. 1
      partner_vat_unique/tests/__init__.py
  10. 22
      partner_vat_unique/tests/test_vat_unique.py

60
partner_vat_unique/README.rst

@ -0,0 +1,60 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
==================
Partner VAT Unique
==================
Module to make the VAT number unique for customers and suppliers. Will not
consider empty VATs as duplicated.
Installation
============
Will not check previous VAT duplicates, so it is recomended make sure there
isn't any duplicated VAT before installation.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
Contributors
------------
* Ismael Calvo <ismael.calvo@es.gt.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Michael Michot <michotm@gmail.com>
Do not contact contributors directly about support or help with technical issues.
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
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.
To contribute to this module, please visit https://odoo-community.org.

1
partner_vat_unique/__init__.py

@ -0,0 +1 @@
from . import models

13
partner_vat_unique/__manifest__.py

@ -0,0 +1,13 @@
# Copyright 2017 Grant Thornton Spain - Ismael Calvo <ismael.calvo@es.gt.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Partner VAT Unique",
"version": "11.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"],
}

28
partner_vat_unique/i18n/es.po

@ -0,0 +1,28 @@
# 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: 2017-11-29 11:43+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: \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 "Partner"
msgstr ""
#. module: partner_vat_unique
#: code:addons/partner_vat_unique/models/res_partner.py:28
#, fuzzy, python-format
msgid "The VAT %s already exists in another partner."
msgstr "¡El NIF debe de ser único por empresa!"

26
partner_vat_unique/i18n/partner_vat_unique.pot

@ -0,0 +1,26 @@
# 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\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 "Partner"
msgstr ""
#. module: partner_vat_unique
#: code:addons/partner_vat_unique/models/res_partner.py:28
#, python-format
msgid "The VAT %s already exists in another partner."
msgstr ""

1
partner_vat_unique/models/__init__.py

@ -0,0 +1 @@
from . import res_partner

29
partner_vat_unique/models/res_partner.py

@ -0,0 +1,29 @@
# Copyright 2017 Grant Thornton Spain - Ismael Calvo <ismael.calvo@es.gt.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models, _
from odoo.exceptions import ValidationError
from odoo.tools import config
class ResPartner(models.Model):
_inherit = 'res.partner'
@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
results = self.env['res.partner'].search_count([
('parent_id', '=', False),
('vat', '=', record.vat),
('id', '!=', record.id)
])
if results:
raise ValidationError(_(
"The VAT %s already exists in another "
"partner.") % record.vat)

BIN
partner_vat_unique/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

1
partner_vat_unique/tests/__init__.py

@ -0,0 +1 @@
from . import test_vat_unique

22
partner_vat_unique/tests/test_vat_unique.py

@ -0,0 +1,22 @@
# Copyright 2017 Grant Thornton Spain - Ismael Calvo <ismael.calvo@es.gt.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import SavepointCase
from odoo.exceptions import ValidationError
class TestVatUnique(SavepointCase):
@classmethod
def setUpClass(cls):
super(TestVatUnique, cls).setUpClass()
cls.partner = cls.env['res.partner'].create({
'name': 'Test partner',
'vat': 'ESA12345674'
})
def test_duplicated_vat_creation(self):
with self.assertRaises(ValidationError):
self.env['res.partner'].with_context(test_vat=True).create({
'name': 'Second partner',
'vat': 'ESA12345674'
})
Loading…
Cancel
Save