You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

  1. # Copyright 2017 Grant Thornton Spain - Ismael Calvo <ismael.calvo@es.gt.com>
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo.tests.common import SavepointCase
  4. from odoo.exceptions import ValidationError
  5. class TestVatUnique(SavepointCase):
  6. @classmethod
  7. def setUpClass(cls):
  8. super(TestVatUnique, cls).setUpClass()
  9. cls.partner_model = cls.env['res.partner']
  10. cls.partner = cls.partner_model.create({
  11. 'name': 'Test partner',
  12. 'vat': 'ESA12345674'
  13. })
  14. def test_duplicated_vat_creation(self):
  15. with self.assertRaises(ValidationError):
  16. self.partner_model.with_context(test_vat=True).create({
  17. 'name': 'Second partner',
  18. 'vat': 'ESA12345674'
  19. })
  20. def test_duplicated_vat_creation_inactive(self):
  21. self.partner.active = False
  22. with self.assertRaises(ValidationError):
  23. self.env['res.partner'].with_context(test_vat=True).create({
  24. 'name': 'Second partner',
  25. 'vat': 'ESA12345674'
  26. })
  27. def test_duplicate_partner(self):
  28. partner_copied = self.partner.copy()
  29. self.assertFalse(partner_copied.vat)