diff --git a/addons/mail/static/src/js/models/mail_failure.js b/addons/mail/static/src/js/models/mail_failure.js index 390b195f8d9..9a007954a5a 100644 --- a/addons/mail/static/src/js/models/mail_failure.js +++ b/addons/mail/static/src/js/models/mail_failure.js @@ -13,6 +13,7 @@ var MailFailure = Class.extend(Mixins.EventDispatcherMixin, ServicesMixin, { /** * @param {mail.Manager} parent * @param {Object} data + * @param {string} data.failure_type * @param {string} data.last_message_date * @param {integer} data.message_id * @param {string} data.model @@ -29,6 +30,7 @@ var MailFailure = Class.extend(Mixins.EventDispatcherMixin, ServicesMixin, { this._documentID = data.res_id; this._documentModel = data.model; + this._failureType = data.failure_type || 'mail'; this._lastMessageDate = moment(); // by default: current datetime this._messageID = data.message_id; this._modelName = data.model_name; @@ -62,6 +64,14 @@ var MailFailure = Class.extend(Mixins.EventDispatcherMixin, ServicesMixin, { getDocumentID: function () { return this._documentID; }, + /** + * Get the type of failure of this mail failure. + * + * @returns {string} + */ + getFailureType: function () { + return this._failureType; + }, /** * Get the ID of the message that this mail failure is related to. * diff --git a/addons/mail/static/src/js/services/mail_manager.js b/addons/mail/static/src/js/services/mail_manager.js index 6a49cdf0183..062b3208066 100644 --- a/addons/mail/static/src/js/services/mail_manager.js +++ b/addons/mail/static/src/js/services/mail_manager.js @@ -676,8 +676,8 @@ var MailManager = AbstractService.extend({ }, /** * Get the previews of the mail failures - * Mail failures of a same model are grouped together, so that there are few - * preview items on the messaging menu in the systray. + * Mail failures of a same model with the same type are grouped together, so + * that there are few preview items on the messaging menu in the systray. * * To determine whether this is a model preview or a document preview review * the documentID is omitted for a model preview, whereas it is set for a @@ -696,10 +696,11 @@ var MailManager = AbstractService.extend({ _.each(this._mailFailures, function (failure) { var unreadCounter = 1; var isSameDocument = true; - var sameModelItem = _.find(items, function (item) { + var sameModelAndTypeItem = _.find(items, function (item) { if ( item.failure.isLinkedToDocument() && - (item.failure.getDocumentModel() === failure.getDocumentModel()) + (item.failure.getDocumentModel() === failure.getDocumentModel()) && + (item.failure.getFailureType() === failure.getFailureType()) ) { isSameDocument = item.failure.getDocumentID() === failure.getDocumentID(); return true; @@ -707,10 +708,10 @@ var MailManager = AbstractService.extend({ return false; }); - if (failure.isLinkedToDocument() && sameModelItem) { - unreadCounter = sameModelItem.unreadCounter + 1; - isSameDocument = sameModelItem.isSameDocument && isSameDocument; - var index = _.findIndex(items, sameModelItem); + if (failure.isLinkedToDocument() && sameModelAndTypeItem) { + unreadCounter = sameModelAndTypeItem.unreadCounter + 1; + isSameDocument = sameModelAndTypeItem.isSameDocument && isSameDocument; + var index = _.findIndex(items, sameModelAndTypeItem); items[index] = { unreadCounter: unreadCounter, failure: failure,