You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
# -*- coding: utf-8 -*-
|
|
from openerp import api, models, fields
|
|
|
|
|
|
class MailMessage(models.Model):
|
|
_inherit = 'mail.message'
|
|
|
|
sent = fields.Boolean('Sent', compute="_compute_sent", help='Was message sent to someone', store=True)
|
|
|
|
@api.depends('author_id', 'partner_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
|
|
r.sent = sent
|
|
|
|
@api.multi
|
|
def message_format(self):
|
|
message_values = super(MailMessage, self).message_format()
|
|
message_index = {message['id']: message for message in message_values}
|
|
for item in self:
|
|
msg = message_index.get(item.id)
|
|
if msg:
|
|
msg['sent'] = item.sent
|
|
return message_values
|
|
|
|
|
|
class MailComposeMessage(models.TransientModel):
|
|
|
|
_inherit = 'mail.compose.message'
|
|
sent = fields.Boolean('Sent', help='dummy field to fix inherit error')
|