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.

33 lines
1.1 KiB

9 years ago
  1. from odoo import api, models, fields
  2. class MailMessage(models.Model):
  3. _inherit = 'mail.message'
  4. sent = fields.Boolean('Sent', compute="_compute_sent", help='Was message sent to someone', store=True)
  5. @api.depends('author_id', 'partner_ids')
  6. def _compute_sent(self):
  7. for r in self:
  8. r_sudo = r.sudo()
  9. sent = len(r_sudo.partner_ids) > 1 \
  10. or len(r_sudo.partner_ids) == 1 \
  11. and r_sudo.author_id \
  12. and r_sudo.partner_ids[0].id != r_sudo.author_id.id
  13. r.sent = sent
  14. @api.multi
  15. def message_format(self):
  16. message_values = super(MailMessage, self).message_format()
  17. message_index = {message['id']: message for message in message_values}
  18. for item in self:
  19. msg = message_index.get(item.id)
  20. if msg:
  21. msg['sent'] = item.sent
  22. return message_values
  23. class MailComposeMessage(models.TransientModel):
  24. _inherit = 'mail.compose.message'
  25. sent = fields.Boolean('Sent', help='dummy field to fix inherit error')