Merge pull request #202 from adhoc-dev/11.0-h-15966-nmr

[IMP] check recusion when select parent
This commit is contained in:
Pedro M. Baeza 2019-01-30 14:06:08 +01:00 committed by GitHub
commit 59eed8b8a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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."""