From a2a4cd56ecae6231242b11307c8ac54aedf9351c Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Tue, 18 Apr 2023 07:47:07 +0000 Subject: [PATCH] [FIX] mail: fix reply to author avatar This PR fixes a bug where the author avatar of the parent message of a reply had the wrong avatar (the one of the of the reply author instead of the one of the parent message author). closes odoo/odoo#118878 Signed-off-by: Debondt Didier (did) --- .../static/src/core_ui/message_in_reply.js | 5 +++- .../tests/message/message_reply_tests.js | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/core_ui/message_in_reply.js b/addons/mail/static/src/core_ui/message_in_reply.js index dfcbbd867c8..f63f4c12766 100644 --- a/addons/mail/static/src/core_ui/message_in_reply.js +++ b/addons/mail/static/src/core_ui/message_in_reply.js @@ -26,6 +26,9 @@ export class MessageInReply extends Component { ) { return url("/mail/static/src/img/email_icon.png"); } - return this.threadService.avatarUrl(this.message.author, this.props.message.originThread); + return this.threadService.avatarUrl( + this.message.parentMessage.author, + this.props.message.parentMessage.originThread + ); } } diff --git a/addons/mail/static/tests/message/message_reply_tests.js b/addons/mail/static/tests/message/message_reply_tests.js index 71c18027c8c..a0a2b0c55f2 100644 --- a/addons/mail/static/tests/message/message_reply_tests.js +++ b/addons/mail/static/tests/message/message_reply_tests.js @@ -62,3 +62,31 @@ QUnit.test("click on message in reply to scroll to the parent message", async (a await nextTick(); assert.isVisible($(".o-mail-Message:eq(0)")); }); + +QUnit.test("reply shows correct author avatar", async (assert) => { + const pyEnv = await startServer(); + const channelId = pyEnv["mail.channel"].create({ name: "general" }); + const messageId = pyEnv["mail.message"].create({ + body: "Hey there", + message_type: "comment", + model: "mail.channel", + res_id: channelId, + }); + const partnerId = pyEnv["res.partner"].create({ name: "John Doe" }); + pyEnv["mail.message"].create({ + body: "Howdy", + message_type: "comment", + model: "mail.channel", + author_id: partnerId, + parent_id: messageId, + res_id: channelId, + }); + const { openDiscuss } = await start(); + await openDiscuss(channelId); + const replyAvatar = document.querySelector(".o-mail-MessageInReply-avatar"); + assert.ok( + replyAvatar.dataset["src"].includes( + `/mail/channel/${channelId}/partner/${pyEnv.currentPartnerId}/avatar_128` + ) + ); +});