From af752e71584f2e99be9e460bdcf88582b6e1d5bd Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Tue, 24 Apr 2018 01:10:02 +0530 Subject: [PATCH] [FIX] website_forum: Fixed maximum recursion depth Before this commit, you can set the question of a post like the post itself. That will generate a traceback: RecursionError: maximum recursion depth exceeded in comparison Now we check that there is no recursion --- addons/website_forum/models/forum.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 59b22290fee..ebe6bd80b2d 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -427,6 +427,11 @@ class Post(models.Model): raise KarmaError('User karma not sufficient to post an image or link.') return content + @api.constrains('parent_id') + def _check_parent_id(self): + if not self._check_recursion(): + raise ValidationError(_('You cannot create recursive forum posts.')) + @api.model def create(self, vals): if 'content' in vals and vals.get('forum_id'):