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.

40 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Antiun Ingenieria S.L. - Javier Iniesta
  3. # © 2016 Tecnativa S.L. - Vicent Cubells
  4. # © 2016 Tecnativa S.L. - Pedro M. Baeza
  5. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  6. from openerp.tests import common
  7. from openerp.exceptions import ValidationError
  8. class TestResPartnerSector(common.SavepointCase):
  9. @classmethod
  10. def setUpClass(cls):
  11. super(TestResPartnerSector, cls).setUpClass()
  12. cls.Sector = cls.env['res.partner.sector']
  13. cls.sector_main = cls.Sector.create({
  14. 'name': 'Test',
  15. })
  16. cls.sector_child = cls.Sector.create({
  17. 'name': 'Test child',
  18. 'parent_id': cls.sector_main.id,
  19. })
  20. def test_check_sectors(self):
  21. with self.assertRaises(ValidationError):
  22. self.env['res.partner'].create({
  23. 'name': 'Test',
  24. 'sector_id': self.sector_main.id,
  25. 'secondary_sector_ids': [(4, self.sector_main.id)],
  26. })
  27. def test_check_recursion(self):
  28. with self.assertRaises(ValidationError):
  29. self.sector_main.parent_id = self.sector_child.id
  30. def test_name(self):
  31. self.assertEqual(
  32. self.sector_child.name_get()[0][1],
  33. "Test / Test child",
  34. )