diff --git a/mail_archives/__manifest__.py b/mail_archives/__manifest__.py index 91c4f81..0165f56 100644 --- a/mail_archives/__manifest__.py +++ b/mail_archives/__manifest__.py @@ -3,7 +3,7 @@ "summary": """Adds menu to find old messages""", "category": "Discuss", "images": ['images/1.jpg'], - "version": "12.0.1.0.0", + "version": "12.0.1.0.1", "author": "IT-Projects LLC, Pavel Romanchenko", "support": "apps@it-projects.info", diff --git a/mail_archives/doc/changelog.rst b/mail_archives/doc/changelog.rst index 9ee2b48..951c9f7 100644 --- a/mail_archives/doc/changelog.rst +++ b/mail_archives/doc/changelog.rst @@ -1,3 +1,10 @@ +`1.0.1` +------- + +- **Fix:** Mails from channels were not downloaded automatically +- **Fix:** Fetching mails from another threads +- **Fix:** Incorrect counter + `1.0.0` ------- diff --git a/mail_archives/static/src/js/archives.js b/mail_archives/static/src/js/archives.js index 279e8e8..c4606e7 100644 --- a/mail_archives/static/src/js/archives.js +++ b/mail_archives/static/src/js/archives.js @@ -5,6 +5,7 @@ var core = require('web.core'); var session = require('web.session'); var Manager = require('mail.Manager'); var Mailbox = require('mail.model.Mailbox'); +var SearchableThread = require('mail.model.SearchableThread'); var _t = core._t; @@ -18,24 +19,62 @@ Manager.include({ this._addMailbox({ id: 'channel_archive', name: _t("Archive"), - mailboxCounter: data.needaction_inbox_counter || 0, + mailboxCounter: 0, }); } }, +}); + +SearchableThread.include({ + _fetchMessages: function (pDomain, loadMore) { + var self = this; + if (this._id !== 'mailbox_channel_archive') { + return this._super(pDomain, loadMore); + } - _makeMessage: function (data) { - var message = this._super(data); - message._addThread('mailbox_channel_archive'); - return message; + // this is a copy-paste from super method + var domain = this._getThreadDomain(); + var cache = this._getCache(pDomain); + if (pDomain) { + domain = domain.concat(pDomain || []); + } + if (loadMore) { + var minMessageID = cache.messages[0].getID(); + domain = [['id', '<', minMessageID]].concat(domain); + } + return this._rpc({ + model: 'mail.message', + method: 'message_fetch', + args: [domain], + kwargs: this._getFetchMessagesKwargs(), + }).then(function (messages) { + // except this function. It adds the required thread to downloaded messages + _.each(messages, function(m){ + m.channel_ids.push('mailbox_channel_archive'); + }); + if (!cache.allHistoryLoaded) { + cache.allHistoryLoaded = messages.length < self._FETCH_LIMIT; + } + cache.loaded = true; + _.each(messages, function (message) { + self.call('mail_service', 'addMessage', message, { + silent: true, + domain: pDomain, + }); + }); + cache = self._getCache(pDomain || []); + return cache.messages; + }); }, }); Mailbox.include({ _getThreadDomain: function () { if (this._id === 'mailbox_channel_archive') { - return ['|', + return ['|','|', ['partner_ids', 'in', [session.partner_id]], - ['author_id', 'in', [session.partner_id]] + ['author_id', 'in', [session.partner_id]], + ['channel_ids.channel_partner_ids', 'in', [session.partner_id]], ]; } return this._super(); diff --git a/mail_archives/static/src/xml/menu.xml b/mail_archives/static/src/xml/menu.xml index cdef0f9..ef56992 100644 --- a/mail_archives/static/src/xml/menu.xml +++ b/mail_archives/static/src/xml/menu.xml @@ -6,8 +6,6 @@
Archive - -