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.

25 lines
901 B

  1. # Copyright 2017 Grant Thornton Spain - Ismael Calvo <ismael.calvo@es.gt.com>
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo.exceptions import ValidationError
  4. from odoo.tests.common import SavepointCase
  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", "vat": "ESA12345674"}
  12. )
  13. def test_duplicated_vat_creation(self):
  14. with self.assertRaises(ValidationError):
  15. self.partner_model.with_context(test_vat=True).create(
  16. {"name": "Second partner", "vat": "ESA12345674"}
  17. )
  18. def test_duplicate_partner(self):
  19. partner_copied = self.partner.copy()
  20. self.assertFalse(partner_copied.vat)