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.

26 lines
913 B

  1. # © 2016 Tecnativa - Vicent Cubells
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
  3. from odoo.exceptions import UserError
  4. from odoo.tests import common
  5. class TestRecursion(common.SavepointCase):
  6. @classmethod
  7. def setUpClass(cls):
  8. super(TestRecursion, cls).setUpClass()
  9. cls.department_obj = cls.env["res.partner.department"]
  10. # Instances
  11. cls.dpt1 = cls.department_obj.create({"name": "Dpt. 1"})
  12. cls.dpt2 = cls.department_obj.create(
  13. {"name": "Dep. 2", "parent_id": cls.dpt1.id}
  14. )
  15. def test_recursion(self):
  16. """Testing recursion"""
  17. self.dpt3 = self.department_obj.create(
  18. {"name": "Dep. 3", "parent_id": self.dpt2.id}
  19. )
  20. # Creating a parent's child department using dpt1.
  21. with self.assertRaises(UserError):
  22. self.dpt1.write(vals={"parent_id": self.dpt3.id})