partner-contact/partner_vat_unique/tests/test_vat_unique.py
2024-05-03 10:58:43 +02:00

26 lines
893 B
Python

# Copyright 2017 Grant Thornton Spain - Ismael Calvo <ismael.calvo@es.gt.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from flectra.exceptions import ValidationError
from flectra.tests.common import TransactionCase
class TestVatUnique(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.partner_model = cls.env["res.partner"]
cls.partner = cls.partner_model.create(
{"name": "Test partner", "vat": "ESA12345674"}
)
def test_duplicated_vat_creation(self):
with self.assertRaises(ValidationError):
self.partner_model.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)