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.

29 lines
951 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({'name': 'Dpt. 1'})
  12. cls.dpt2 = cls.department_obj.create({
  13. 'name': 'Dep. 2',
  14. 'parent_id': cls.dpt1.id
  15. })
  16. def test_recursion(self):
  17. """ Testing recursion """
  18. self.dpt3 = self.department_obj.create({
  19. 'name': 'Dep. 3',
  20. 'parent_id': self.dpt2.id
  21. })
  22. # Creating a parent's child department using dpt1.
  23. with self.assertRaises(ValidationError):
  24. self.dpt1.write(vals={'parent_id': self.dpt3.id})