From e7cb3dcaa8a26b254a78d07cb0eb95946440edaa Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 1 Dec 2015 08:58:28 +0100 Subject: [PATCH] [FIX] mail: don't redirect to user's own partner form view Clicking on the author of a message opens a DM with the corresponding user if there is one, and opens the corresponding partner's form view otherwise. When the author is the current user, obviously we don't want to open a DM with ourself, but we probably don't want to open our partner form view either, which was exactly the behavior before this rev. --- addons/mail/static/src/js/chat_manager.js | 7 +++++++ addons/mail/static/src/xml/thread.xml | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index adf1b5f6b57..c9cf65ac883 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -148,6 +148,13 @@ function make_message (data) { msg.email_from || _t('Anonymous'); } + // Don't redirect on author clicked of self-posted messages + if (msg.author_id && msg.author_id[0] === session.partner_id) { + msg.author_redirect = false; + } else { + msg.author_redirect = true; + } + // Compute the avatar_url if (msg.author_id && msg.author_id[0]) { msg.avatar_src = "/web/image/res.partner/" + msg.author_id[0] + "/image_small"; diff --git a/addons/mail/static/src/xml/thread.xml b/addons/mail/static/src/xml/thread.xml index ebf6687c1a3..48ba98659b2 100644 --- a/addons/mail/static/src/xml/thread.xml +++ b/addons/mail/static/src/xml/thread.xml @@ -53,7 +53,7 @@ t-att-src="message.avatar_src" data-oe-model="res.partner" t-att-data-oe-id="message.author_id[0]" - class="o_thread_message_avatar o_mail_redirect"/> + t-attf-class="o_thread_message_avatar #{message.author_redirect ? 'o_mail_redirect' : ''}"/> + t-attf-class="#{message.author_redirect ? 'o_mail_redirect' : ''}">