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.

27 lines
928 B

  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_duplicate_partner(self):
  21. partner_copied = self.partner.copy()
  22. self.assertFalse(partner_copied.vat)