[IMP] check recusion when select parent

This commit is contained in:
nicomacr 2019-01-28 13:06:30 -03:00 committed by Justine Doutreloux
parent 2300c2bcfb
commit 7f5f19a95f

View File

@ -1,7 +1,8 @@
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
class DocumentPage(models.Model):
@ -112,6 +113,11 @@ class DocumentPage(models.Model):
ondelete='cascade',
)
@api.constrains('parent_id')
def _check_parent_id(self):
if not self._check_recursion():
raise ValidationError(_('You cannot create recursive categories.'))
@api.multi
def _get_page_index(self, link=True):
"""Return the index of a document."""