diff --git a/document_page/models/document_page.py b/document_page/models/document_page.py index 5ec91dea..56f8c385 100644 --- a/document_page/models/document_page.py +++ b/document_page/models/document_page.py @@ -1,7 +1,8 @@ # Copyright (C) 2004-2010 Tiny SPRL (). # 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."""