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.

37 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.exceptions import ValidationError
  6. from odoo.tests import common
  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({"name": "Test",})
  13. cls.industry_child = cls.industry_model.create(
  14. {"name": "Test child", "parent_id": cls.industry_main.id,}
  15. )
  16. def test_check_industries(self):
  17. with self.assertRaises(ValidationError):
  18. self.env["res.partner"].create(
  19. {
  20. "name": "Test",
  21. "industry_id": self.industry_main.id,
  22. "secondary_industry_ids": [(4, self.industry_main.id)],
  23. }
  24. )
  25. def test_check_recursion(self):
  26. with self.assertRaises(ValidationError):
  27. self.industry_main.parent_id = self.industry_child.id
  28. def test_name(self):
  29. self.assertEqual(
  30. self.industry_child.name_get()[0][1], "Test / Test child",
  31. )