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.

31 lines
1018 B

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