From 8f546bfad17d631d481745c471feffbbb93326a1 Mon Sep 17 00:00:00 2001 From: Shahnawaz Idariya Date: Tue, 26 Oct 2021 16:52:42 +0000 Subject: [PATCH] [FIX] mail: fix traceback on emoji MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit: When trying to select emoji on log note before record creation, it shows traceback. After this commit: Hiding the emoji button when the record is under creation. Task-2664700 closes odoo/odoo#80352 X-original-commit: 10c06f9753540d0a58b1a93fc54947a58b092468 Signed-off-by: Sébastien Theys (seb) --- .../components/chatter/tests/chatter_tests.js | 16 +++++++++++++++- .../message_action_list/message_action_list.xml | 2 +- addons/mail/static/src/models/message/message.js | 12 ++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/components/chatter/tests/chatter_tests.js b/addons/mail/static/src/components/chatter/tests/chatter_tests.js index 97fbd2a1e42..77f18c0903d 100644 --- a/addons/mail/static/src/components/chatter/tests/chatter_tests.js +++ b/addons/mail/static/src/components/chatter/tests/chatter_tests.js @@ -91,7 +91,7 @@ QUnit.test('base rendering when chatter has no attachment', async function (asse }); QUnit.test('base rendering when chatter has no record', async function (assert) { - assert.expect(8); + assert.expect(10); await this.start(); const chatter = this.messaging.models['mail.chatter'].create({ @@ -138,6 +138,20 @@ QUnit.test('base rendering when chatter has no record', async function (assert) '.o_MessageList_loadMore', "should not have the 'load more' button" ); + + await afterNextRender(() => + document.querySelector('.o_Message').click() + ); + assert.strictEqual( + document.querySelectorAll(`.o_MessageActionList`).length, + 1, + "should action list in message" + ); + assert.containsNone( + document.body, + '.o_MessageActionList_action', + "should not have any action in action list of message" + ); }); QUnit.test('base rendering when chatter has attachments', async function (assert) { diff --git a/addons/mail/static/src/components/message_action_list/message_action_list.xml b/addons/mail/static/src/components/message_action_list/message_action_list.xml index 138dff38191..fc52fe1cf3e 100644 --- a/addons/mail/static/src/components/message_action_list/message_action_list.xml +++ b/addons/mail/static/src/components/message_action_list/message_action_list.xml @@ -3,7 +3,7 @@
- + diff --git a/addons/mail/static/src/models/message/message.js b/addons/mail/static/src/models/message/message.js index 56ac9394f9e..db1ed60c2cf 100644 --- a/addons/mail/static/src/models/message/message.js +++ b/addons/mail/static/src/models/message/message.js @@ -364,6 +364,12 @@ registerModel({ _computeFailureNotifications() { return replace(this.notifications.filter(notifications => notifications.isFailure)); }, + /** + * @returns {boolean} + */ + _computeHasReactionIcon() { + return !this.isTemporary && !this.isTransient; + }, /** * @private * @returns {boolean} @@ -578,6 +584,12 @@ registerModel({ guestAuthor: many2one('mail.guest', { inverse: 'authoredMessages', }), + /** + * Determines whether the message has a reaction icon. + */ + hasReactionIcon: attr({ + compute: '_computeHasReactionIcon', + }), id: attr({ readonly: true, required: true,