Browse Source

[FIX] move filtration from models.py to sent.js that "sent" in models.py and "sent" in js have same meaning

[FIX] change partner_ids to needaction_partner_ids
pull/6/head
x620 9 years ago
parent
commit
116fa9e80d
  1. 12
      mail_sent/models.py
  2. 2
      mail_sent/static/src/js/sent.js

12
mail_sent/models.py

@ -8,13 +8,13 @@ class MailMessage(models.Model):
sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True) sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True)
@api.one @api.one
@api.depends('author_id', 'partner_ids')
@api.depends('author_id', 'needaction_partner_ids')
def _get_sent(self): def _get_sent(self):
self_sudo = self.sudo() self_sudo = self.sudo()
self_sudo.sent = len(self_sudo.partner_ids) > 1 \
or len(self_sudo.partner_ids) == 1 \
and self_sudo.author_id \
and self_sudo.partner_ids[0].id != self_sudo.author_id.id
self_sudo.sent = len(self_sudo.needaction_partner_ids) > 1 \
or len(self_sudo.needaction_partner_ids) == 1 \
and self_sudo.author_id \
and self_sudo.needaction_partner_ids[0].id != self_sudo.author_id.id
@api.multi @api.multi
def message_format(self): def message_format(self):
@ -22,7 +22,7 @@ class MailMessage(models.Model):
message_index = {message['id']: message for message in message_values} message_index = {message['id']: message for message in message_values}
for item in self: for item in self:
msg = message_index.get(item.id) msg = message_index.get(item.id)
if msg and item._uid == item.author_id.user_ids.id:
if msg:
msg['sent'] = item.sent msg['sent'] = item.sent
return message_values return message_values

2
mail_sent/static/src/js/sent.js

@ -26,7 +26,7 @@ base_obj.MailTools.include({
set_channel_flags: function(data, msg){ set_channel_flags: function(data, msg){
this._super.apply(this, arguments); this._super.apply(this, arguments);
if (data.sent) {
if (data.sent && data.author_id[0] == session.partner_id && data.partner_ids.length > 0) {
msg.is_sent = true; msg.is_sent = true;
} }
return msg; return msg;

Loading…
Cancel
Save