mirror of
https://gitlab.com/flectra-community/partner-contact.git
synced 2024-12-24 13:21:48 +00:00
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# 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 flectra.tests.common import SavepointCase
|
|
from flectra.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'
|
|
})
|
|
|
|
def test_duplicated_vat_creation_inactive(self):
|
|
self.partner.active = False
|
|
with self.assertRaises(ValidationError):
|
|
self.env['res.partner'].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)
|