diff --git a/partner_ref_unique/README.rst b/partner_ref_unique/README.rst index 7a8502323..e4a903827 100644 --- a/partner_ref_unique/README.rst +++ b/partner_ref_unique/README.rst @@ -8,27 +8,52 @@ Partner unique reference Add an unique constraint to partner ref field +Usage +===== + +To use this module, you need to: + +* Go to your company settings and choose an option on section *Partner* in tab + *Configuration*. +* Try to create two partners with the same ref. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/134/9.0 + +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. + Credits ======= +Images +------ + +* Odoo Community Association: `Icon `_. + Contributors ------------ * Antonio Espinosa +* Vicent Cubells Maintainer ---------- -.. image:: http://www.antiun.com/images/logo-b.png - :alt: Antiun Ingeniería S.L. - :target: http://www.antiun.com - -This module is maintained by Antiun Ingeniería S.L. +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org -Antiun Ingeniería S.L. is an IT consulting company especialized in Odoo -and provides Odoo development, install, maintenance and hosting -services. +This module is maintained by the OCA. -To contribute to this module, please visit https://github.com/Antiun -or contact us at odoo@antiun.com +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. diff --git a/partner_ref_unique/__init__.py b/partner_ref_unique/__init__.py index 6b49297d7..5a5c25ccb 100644 --- a/partner_ref_unique/__init__.py +++ b/partner_ref_unique/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/partner_ref_unique/__openerp__.py b/partner_ref_unique/__openerp__.py index 9a611b5eb..0b8490f6f 100644 --- a/partner_ref_unique/__openerp__.py +++ b/partner_ref_unique/__openerp__.py @@ -1,30 +1,24 @@ # -*- coding: utf-8 -*- -# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2017 Tecnativa - Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Partner unique reference", "summary": "Add an unique constraint to partner ref field", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "category": "Customer Relationship Management", "website": "http://www.antiun.com", - "author": "Antiun Ingeniería S.L.", + "author": "Antiun Ingeniería S.L., " + "Tecnativa, " + "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, - # 'auto_install':False, - "external_dependencies": { - "python": [], - "bin": [], - }, "depends": [ "base", ], "data": [ "views/res_company_view.xml", ], - "demo": [ - ], - "qweb": [ - ] } diff --git a/partner_ref_unique/models/__init__.py b/partner_ref_unique/models/__init__.py index 0b15881ca..f33d10808 100644 --- a/partner_ref_unique/models/__init__.py +++ b/partner_ref_unique/models/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import res_company diff --git a/partner_ref_unique/models/res_company.py b/partner_ref_unique/models/res_company.py index 5b0909de9..0cae5c203 100644 --- a/partner_ref_unique/models/res_company.py +++ b/partner_ref_unique/models/res_company.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, fields diff --git a/partner_ref_unique/models/res_partner.py b/partner_ref_unique/models/res_partner.py index fe76d9192..14adeb0e6 100644 --- a/partner_ref_unique/models/res_partner.py +++ b/partner_ref_unique/models/res_partner.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa +# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, api, _ diff --git a/partner_ref_unique/static/description/icon.png b/partner_ref_unique/static/description/icon.png index 2d8a45c39..3a0328b51 100644 Binary files a/partner_ref_unique/static/description/icon.png and b/partner_ref_unique/static/description/icon.png differ diff --git a/partner_ref_unique/tests/__init__.py b/partner_ref_unique/tests/__init__.py new file mode 100644 index 000000000..00432e6ea --- /dev/null +++ b/partner_ref_unique/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Vicent Cubells +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_res_partner_ref diff --git a/partner_ref_unique/tests/test_res_partner_ref.py b/partner_ref_unique/tests/test_res_partner_ref.py new file mode 100644 index 000000000..32ff32e0c --- /dev/null +++ b/partner_ref_unique/tests/test_res_partner_ref.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Vicent Cubells +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.tests import common +from openerp.exceptions import ValidationError + + +class TestResPartnerRefUnique(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestResPartnerRefUnique, cls).setUpClass() + cls.company = cls.env.ref('base.main_company') + partner_obj = cls.env['res.partner'] + cls.partner1 = partner_obj.create({ + 'name': 'Partner1', + }) + cls.partner2 = partner_obj.create({ + 'name': 'Partner2', + }) + + def test_check_ref(self): + # Test can create/modify partners with same ref + self.company.partner_ref_unique = 'none' + self.partner1.ref = 'same_ref' + self.partner2.ref = 'same_ref' + self.assertEqual(self.partner1.ref, self.partner2.ref) + self.partner2.ref = False + + # Test can't create/modify partner with same ref + self.company.partner_ref_unique = 'all' + with self.assertRaises(ValidationError): + self.partner2.ref = 'same_ref' + + # Test can't create/modify companies with same ref + self.company.partner_ref_unique = 'companies' + self.partner2.ref = 'same_ref' + self.assertEqual(self.partner1.ref, self.partner2.ref) + self.partner2.ref = False + self.partner1.is_company = True + self.partner2.is_company = True + with self.assertRaises(ValidationError): + self.partner2.ref = 'same_ref' diff --git a/partner_ref_unique/views/res_company_view.xml b/partner_ref_unique/views/res_company_view.xml index 261567487..c8cb6f485 100644 --- a/partner_ref_unique/views/res_company_view.xml +++ b/partner_ref_unique/views/res_company_view.xml @@ -1,15 +1,15 @@ - - - + Add partner_ref_unique field res.company - + @@ -19,5 +19,4 @@ - - +