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.

39 lines
1.3 KiB

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