[FIX] website_forum: allow new user to see own pending post

How to reproduce the bug:
------------------------

- Create a new user
- Log in as that user
- Go to a forum that don't require karma to ask a question.
- Create a new post
- On validation, you'll end up on a 404 page.

If we use the portal user instead, we see the post with a banner explaining
it has to be validated. This should be the result here too.

Specifications:
--------------

- When new users (karma = 0) create a post, redirect them to the page
relating to their question.

task-3372016

closes odoo/odoo#130857

X-original-commit: 9f624795c68d69ddf212657fe43cc45fc32747a0
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
This commit is contained in:
Lopes Marc (loma)
2023-08-07 10:58:37 +02:00
parent 444d20bd94
commit 6c3c4fe370
+1 -1
View File
@@ -259,7 +259,7 @@ class Post(models.Model):
post.can_downvote = is_admin or user.karma >= post.forum_id.karma_downvote or post.user_vote == 1
post.can_comment = is_admin or user.karma >= post.karma_comment
post.can_comment_convert = is_admin or user.karma >= post.karma_comment_convert
post.can_view = is_admin or user.karma >= post.karma_close or (post_sudo.create_uid.karma > 0 and (post_sudo.active or post_sudo.create_uid == user))
post.can_view = post.can_close or post_sudo.active and (post_sudo.create_uid.karma > 0 or post_sudo.create_uid == user)
post.can_display_biography = is_admin or (post_sudo.create_uid.karma >= post.forum_id.karma_user_bio and post_sudo.create_uid.website_published)
post.can_post = is_admin or user.karma >= post.forum_id.karma_post
post.can_flag = is_admin or user.karma >= post.forum_id.karma_flag