[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
This commit is contained in:
Swapnesh Shah
2018-06-11 16:49:38 +02:00
committed by Jeremy Kersten
parent 66182a5645
commit af752e7158
+5
View File
@@ -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'):