[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) <tbe@odoo.com>
This commit is contained in:
Rémi Rahir
2020-02-27 20:01:19 +00:00
parent 202f7119ae
commit c45f4ebc42
+2 -1
View File
@@ -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()