From c45f4ebc423ffbdbdc89826c9e91f468810fa40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir?= Date: Wed, 19 Feb 2020 13:07:33 +0000 Subject: [PATCH] [FIX] website_forum: wrong user displayed on forum The function to convert an answer to a comment was creating a new message with the create_uid of the current user instead of the original poster, therefore creating a mismatch between the create_uid and the user of the message author. Since the template 'website_forum.author_box' was designed to work with different objects (mail.message & forum.post), it displays the information of the object.create_uid which is not the correct user in this case. This commit ensures that we create the message with the correct user to avoid the mismatch. closes odoo/odoo#46486 X-original-commit: 20800955257c4f871cc21f8e21cd22c1a3b0fe9f Signed-off-by: Toufik Benjaa (tbe) --- addons/website_forum/models/forum.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 4e0ba27fa61..9f17605b690 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -720,7 +720,8 @@ class Post(models.Model): 'subtype_xmlid': 'mail.mt_comment', 'date': self.create_date, } - new_message = question.with_context(mail_create_nosubscribe=True).message_post(**values) + # 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) # unlink the original answer, using SUPERUSER_ID to avoid karma issues self.sudo().unlink()