diff --git a/addons/mail/static/src/js/models/threads/document_thread.js b/addons/mail/static/src/js/models/threads/document_thread.js index 6c15b39d25e..8e354a6e93c 100644 --- a/addons/mail/static/src/js/models/threads/document_thread.js +++ b/addons/mail/static/src/js/models/threads/document_thread.js @@ -329,7 +329,9 @@ var DocumentThread = Thread.extend({ .then(function (messages) { messages[0].model = resModel; messages[0].res_id = resID; - self.call('mail_service', 'addMessage', messages[0]); + self.call('mail_service', 'addMessage', messages[0], { + postedFromDocumentThread: true, + }); return messages[0]; }); }); diff --git a/addons/mail/static/src/js/services/mail_document_thread_manager.js b/addons/mail/static/src/js/services/mail_document_thread_manager.js index a98ae317c9d..000a1c15fa5 100644 --- a/addons/mail/static/src/js/services/mail_document_thread_manager.js +++ b/addons/mail/static/src/js/services/mail_document_thread_manager.js @@ -48,23 +48,16 @@ MailManager.include({ * * @override * @param {Object} data - * @param {Array} [data.author_id] [int, string] where int is server ID of - * the author, and string is the name of the author. * @param {integer} data.id server ID of the message - * @param {string} [data.model] the model name of the document that this - * message is related to. - * @param {integer} [data.res_id] the ID of the document that this message - * is related to. - * + * @param {Object} [options] + * @param {boolean} [options.postedFromDocumentThread=false] */ - addMessage: function (data) { + addMessage: function (data, options) { var message = this.getMessage(data.id); if ( !message && - data.res_id && - data.model && - data.author_id && - data.author_id[0] === session.partner_id + options && + options.postedFromDocumentThread ) { var key = this.DOCUMENT_THREAD_MESSAGE_KEY; this.call('local_storage', 'setItem', key, data); diff --git a/addons/mail/static/tests/document_thread_window_tests.js b/addons/mail/static/tests/document_thread_window_tests.js index 93095362306..2fcd89c444e 100644 --- a/addons/mail/static/tests/document_thread_window_tests.js +++ b/addons/mail/static/tests/document_thread_window_tests.js @@ -48,7 +48,7 @@ QUnit.module('Document Thread', { }, records: [{ id: 1, - author_id: [1, 'Me'], + author_id: [partnerID, 'Me'], body: '
Some Message on a document
', channel_ids: [], model: 'some.res.model',