From aaad54bdac42ca1e85f37a2a2acdbf1f3ee522fd Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Fri, 31 Jul 2020 07:37:53 +0000 Subject: [PATCH] [FIX] website_forum: error when converting answer/comment - Create 2 companies (A and B for instance); - Create 2 users with password, one on each company (user 'a' in company A and user 'b' in company B); - Add enough karma on both users; - Add a valid email address to both users; - As user 'b' : - open any forum topic and validate the email address; - post an answer or comment to a forum post; - As user 'a' : - open the forum and find the answer/comment made by user 'b'; - convert the answer as comment or convert a comment as answer; Before this commit, an error was raised : 'Access to unauthorized or invalid companies'. opw-2296470 closes odoo/odoo#55301 X-original-commit: ce63a20ca26f1773ea7e1133b0a3796fda692e11 Signed-off-by: Jorge Pinna Puissant (jpp) --- addons/website_forum/models/forum.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 8ea075febd3..aa1bc38af39 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -780,7 +780,7 @@ class Post(models.Model): 'date': self.create_date, } # done with the author user to have create_uid correctly set - new_message = question.with_user(self_sudo.create_uid.id).with_context(mail_create_nosubscribe=True).message_post(**values) + new_message = question.with_user(self_sudo.create_uid.id).with_context(mail_create_nosubscribe=True).sudo().message_post(**values).sudo(False) # unlink the original answer, using SUPERUSER_ID to avoid karma issues self.sudo().unlink() @@ -824,7 +824,7 @@ class Post(models.Model): 'name': _('Re: %s') % (question.name or ''), } # done with the author user to have create_uid correctly set - new_post = self.with_user(post_create_uid).create(post_values) + new_post = self.with_user(post_create_uid).sudo().create(post_values).sudo(False) # delete comment comment.unlink()