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
1005 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.job_obj = cls.env['res.partner.job_position']
  11. # Instances
  12. cls.grand_parent = cls.job_obj.create(vals=dict(name='Grand parent'))
  13. cls.parent = cls.job_obj.create(vals=dict(
  14. name='Parent',
  15. parent_id=cls.grand_parent.id
  16. ))
  17. def test_recursion(self):
  18. """ Testing recursion """
  19. self.child = self.job_obj.create(vals=dict(
  20. name='Grand parent',
  21. parent_id=self.parent.id
  22. ))
  23. # Creating a parent's child using grand-parent
  24. with self.assertRaises(ValidationError):
  25. self.grand_parent.write(vals={'parent_id': self.child.id})