Browse Source

🚑 mail_archive: mails from channels were not downloaded automatically; mail_all: incorrect counter; mail_sent: fetches messages from channels (#210)

* 🚑 mail_archives various errors

* 🚑 mail_all incorrect counter

*  mail_sent fetching mails from channels
pull/219/head
ILMIR 5 years ago
committed by GitHub
parent
commit
5d0ce486d5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      mail_all/README.rst
  2. 2
      mail_all/__manifest__.py
  3. 5
      mail_all/doc/changelog.rst
  4. 2
      mail_all/static/src/js/mail_all.js
  5. 2
      mail_all/static/src/xml/menu.xml
  6. 2
      mail_archives/__manifest__.py
  7. 7
      mail_archives/doc/changelog.rst
  8. 53
      mail_archives/static/src/js/archives.js
  9. 2
      mail_archives/static/src/xml/menu.xml
  10. 2
      mail_sent/__manifest__.py
  11. 6
      mail_sent/doc/changelog.rst
  12. 23
      mail_sent/models.py
  13. 48
      mail_sent/static/src/js/sent.js

6
mail_all/README.rst

@ -23,7 +23,7 @@ Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/11.0/mail_all/>`__.
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/mail_all/>`__.
Thank you for understanding!
@ -32,9 +32,9 @@ Maintainers
Further information
===================
Demo: http://runbot.it-projects.info/demo/mail_addons/11.0
Demo: http://runbot.it-projects.info/demo/mail_addons/12.0
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_all/
HTML Description: https://apps.odoo.com/apps/modules/12.0/mail_all/
Usage instructions: `<doc/index.rst>`_

2
mail_all/__manifest__.py

@ -8,7 +8,7 @@
"category": "Discuss",
# "live_test_url": "",
"images": ['images/1.jpg'],
"version": "12.0.1.0.0",
"version": "12.0.1.0.1",
"application": False,
"author": "IT-Projects LLC, Pavel Romanchenko",

5
mail_all/doc/changelog.rst

@ -1,3 +1,8 @@
`1.0.1`
-------
- **Fix:** Incorrect counter
`1.0.0`
-------

2
mail_all/static/src/js/mail_all.js

@ -21,7 +21,7 @@ Manager.include({
this._addMailbox({
id: 'channel_all',
name: _t("All Messages"),
mailboxCounter: data.needaction_inbox_counter || 0,
mailboxCounter: 0,
});
}
},

2
mail_all/static/src/xml/menu.xml

@ -8,8 +8,6 @@
<t t-jquery="div[data-thread-id=mailbox_starred]" t-operation="after">
<div t-attf-class="o_mail_discuss_title_main o_mail_mailbox_title_all o_mail_discuss_item #{(activeThreadID == 'channel_all') ? 'o_active': ''}" data-thread-id="mailbox_channel_all">
<span class="o_channel_name mail_all"> <i class="fa fa-database"/> All messages </span>
<t t-set="counter" t-value="starredCounter"/>
<t t-call="mail.discuss.SidebarCounter"/>
</div>
</t>
</t>

2
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",

7
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`
-------

53
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();

2
mail_archives/static/src/xml/menu.xml

@ -6,8 +6,6 @@
<div t-attf-class="o_mail_discuss_title_main o_mail_discuss_item #{(activeThreadID == 'channel_archive') ? 'o_active': ''}"
data-thread-id="mailbox_channel_archive">
<span class="o_channel_name mail_archives"> <i class="fa fa-archive"/> Archive </span>
<t t-set="counter" t-value="starredCounter"/>
<t t-call="mail.discuss.SidebarCounter"/>
</div>
</t>
</t>

2
mail_sent/__manifest__.py

@ -3,7 +3,7 @@
"summary": """Quick way to find sent messages""",
"category": "Discuss",
"images": ['images/menu.png'],
"version": "12.0.1.0.4",
"version": "12.0.1.1.0",
"author": "IT-Projects LLC, Ivan Yelizariev, Pavel Romanchenko",
"support": "apps@it-projects.info",

6
mail_sent/doc/changelog.rst

@ -1,3 +1,9 @@
`1.1.0`
-------
- **Imp:** Fetches messages from channels
- **Fix:** Fetching mails from another threads
`1.0.4`
-------
- **FIX:** didn't work for non-admin users

23
mail_sent/models.py

@ -6,14 +6,27 @@ class MailMessage(models.Model):
sent = fields.Boolean('Sent', compute="_compute_sent", help='Was message sent to someone', store=True)
@api.depends('author_id', 'partner_ids')
@api.depends('author_id', 'partner_ids', 'channel_ids')
def _compute_sent(self):
for r in self:
r_sudo = r.sudo()
sent = len(r_sudo.partner_ids) > 1 \
or len(r_sudo.partner_ids) == 1 \
and r_sudo.author_id \
and r_sudo.partner_ids[0].id != r_sudo.author_id.id
recipient_ids = r_sudo.partner_ids
author_id = r_sudo.author_id
res_id = r_sudo.model and r_sudo.res_id and r_sudo.env[r_sudo.model].browse(r_sudo.res_id)
sent = author_id and (
len(recipient_ids) > 1
or (
len(recipient_ids) == 1
and recipient_ids[0].id != author_id.id
)
or (
len(r_sudo.channel_ids)
)
or (
res_id
and len(res_id.message_partner_ids - author_id) > 0
)
)
r.sent = sent
@api.multi

48
mail_sent/static/src/js/sent.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,15 +19,52 @@ Manager.include({
this._addMailbox({
id: 'channel_sent',
name: _t("Sent Messages"),
mailboxCounter: data.needaction_inbox_counter || 0,
mailboxCounter: 0,
});
}
},
});
SearchableThread.include({
_fetchMessages: function (pDomain, loadMore) {
var self = this;
if (this._id !== 'mailbox_channel_sent') {
return this._super(pDomain, loadMore);
}
_makeMessage: function (data) {
var message = this._super(data);
message._addThread('mailbox_channel_sent');
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_sent');
});
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;
});
},
});

Loading…
Cancel
Save