mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-14 01:41:26 -06:00
[IMP] check recusion when select parent
This commit is contained in:
parent
2300c2bcfb
commit
7f5f19a95f
@ -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."""
|
||||
|
Loading…
Reference in New Issue
Block a user