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.

30 lines
988 B

  1. # © 2016 Tecnativa - Vicent Cubells
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
  3. from odoo.tests import common
  4. from odoo.exceptions import ValidationError
  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(vals=dict(name='Dpt. 1'))
  12. cls.dpt2 = cls.department_obj.create(
  13. vals=dict(
  14. name='Dpt. 2',
  15. parent_id=cls.dpt1.id
  16. ))
  17. def test_recursion(self):
  18. """ Testing recursion """
  19. self.dpt3 = self.department_obj.create(vals=dict(
  20. name='Dpt. 3',
  21. parent_id=self.dpt2.id
  22. ))
  23. # Creating a parent's child department using dpt1.
  24. with self.assertRaises(ValidationError):
  25. self.dpt1.write(vals={'parent_id': self.dpt3.id})