diff --git a/addons/im_livechat/static/src/models/message_view.js b/addons/im_livechat/static/src/models/message_view.js new file mode 100644 index 00000000000..beacd7071ef --- /dev/null +++ b/addons/im_livechat/static/src/models/message_view.js @@ -0,0 +1,22 @@ +/** @odoo-module **/ + +import { Patch } from '@mail/model'; + +Patch({ + name: "MessageView", + fields: { + hasAuthorClickable: { + compute() { + if ( + this.message && + this.message.originThread && + this.message.originThread.channel && + this.message.originThread.channel.channel_type === "livechat" + ) { + return this.message.author === this.message.originThread.channel.correspondent; + } + return this._super(); + }, + }, + }, +}); diff --git a/addons/mail/i18n/mail.pot b/addons/mail/i18n/mail.pot index 67be94ccc2c..07fca3a8c52 100644 --- a/addons/mail/i18n/mail.pot +++ b/addons/mail/i18n/mail.pot @@ -6665,6 +6665,13 @@ msgstr "" msgid "Open chat" msgstr "" +#. module: mail +#. odoo-javascript +#: code:addons/mail/static/src/models/message_view.js:0 +#, python-format +msgid "Open profile" +msgstr "" + #. module: mail #. odoo-javascript #: code:addons/mail/static/src/models/call_systray_menu.js:0 diff --git a/addons/mail/static/src/components/message/message.xml b/addons/mail/static/src/components/message/message.xml index e96eef8fa04..bc691942c06 100644 --- a/addons/mail/static/src/components/message/message.xml +++ b/addons/mail/static/src/components/message/message.xml @@ -30,7 +30,7 @@
- +
- + diff --git a/addons/mail/static/src/models/message_view.js b/addons/mail/static/src/models/message_view.js index b685547f642..e2e1e5f2ecf 100644 --- a/addons/mail/static/src/models/message_view.js +++ b/addons/mail/static/src/models/message_view.js @@ -79,7 +79,11 @@ Model({ */ onClickAuthorAvatar(ev) { markEventHandled(ev, "Message.ClickAuthorAvatar"); + if (!this.message.author || !this.hasAuthorClickable) { + return; + } if (!this.hasAuthorOpenChat) { + this.message.author.openProfile(); return; } this.message.author.openChat(); @@ -89,7 +93,11 @@ Model({ */ onClickAuthorName(ev) { markEventHandled(ev, "Message.ClickAuthorName"); - if (!this.message.author) { + if (!this.message.author || !this.hasAuthorClickable) { + return; + } + if (!this.hasAuthorOpenChat) { + this.message.author.openProfile(); return; } this.message.author.openChat(); @@ -342,7 +350,11 @@ Model({ }), authorTitleText: attr({ compute() { - return this.hasAuthorOpenChat ? this.env._t("Open chat") : ""; + return this.hasAuthorOpenChat + ? this.env._t("Open chat") + : this.hasAuthorClickable + ? this.env._t("Open profile") + : ""; }, }), clockWatcher: one("ClockWatcher", { @@ -447,6 +459,11 @@ Model({ return true; }, }), + hasAuthorClickable: attr({ + compute() { + return this.hasAuthorOpenChat; + }, + }), /** * Current timer that will reset isHighlighted to false. */