Browse Source

[IMP] partner_ref_unique: Extend tests use cases

pull/670/head
Pedro M. Baeza 6 years ago
committed by sbejaoui
parent
commit
ab4a91c0da
  1. 30
      partner_ref_unique/tests/test_res_partner_ref.py

30
partner_ref_unique/tests/test_res_partner_ref.py

@ -10,11 +10,11 @@ class TestResPartnerRefUnique(common.SavepointCase):
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({
cls.partner_obj = cls.env['res.partner']
cls.partner1 = cls.partner_obj.create({
'name': 'Partner1',
})
cls.partner2 = partner_obj.create({
cls.partner2 = cls.partner_obj.create({
'name': 'Partner2',
})
@ -24,13 +24,21 @@ class TestResPartnerRefUnique(common.SavepointCase):
self.partner1.ref = 'same_ref'
self.partner2.ref = 'same_ref'
self.assertEqual(self.partner1.ref, self.partner2.ref)
# Here there shouldn't be any problem
self.partner_obj.create({
'name': 'other',
'ref': 'same_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'
with self.assertRaises(ValidationError):
self.partner_obj.create({
'name': 'other',
'ref': 'same_ref',
})
# Test can't create/modify companies with same ref
self.company.partner_ref_unique = 'companies'
self.partner2.ref = 'same_ref'
@ -40,3 +48,15 @@ class TestResPartnerRefUnique(common.SavepointCase):
self.partner2.is_company = True
with self.assertRaises(ValidationError):
self.partner2.ref = 'same_ref'
with self.assertRaises(ValidationError):
self.partner_obj.create({
'is_company': True,
'name': 'other',
'ref': 'same_ref',
})
# Here there shouldn't be any problem
self.partner_obj.create({
'is_company': False,
'name': 'other',
'ref': 'same_ref',
})
Loading…
Cancel
Save