cubells
8 years ago
10 changed files with 98 additions and 32 deletions
-
45partner_ref_unique/README.rst
-
2partner_ref_unique/__init__.py
-
18partner_ref_unique/__openerp__.py
-
2partner_ref_unique/models/__init__.py
-
2partner_ref_unique/models/res_company.py
-
2partner_ref_unique/models/res_partner.py
-
BINpartner_ref_unique/static/description/icon.png
-
5partner_ref_unique/tests/__init__.py
-
43partner_ref_unique/tests/test_res_partner_ref.py
-
11partner_ref_unique/views/res_company_view.xml
@ -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 |
@ -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": [ |
|||
] |
|||
} |
@ -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 |
|||
|
Before Width: 128 | Height: 128 | Size: 11 KiB After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -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 |
@ -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' |
Write
Preview
Loading…
Cancel
Save
Reference in new issue