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.

32 lines
1.1 KiB

9 years ago
  1. # -*- coding: utf-8 -*-
  2. from openerp import api, models, fields
  3. class MailMessage(models.Model):
  4. _inherit = 'mail.message'
  5. sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True)
  6. @api.one
  7. @api.depends('author_id', 'needaction_partner_ids')
  8. def _get_sent(self):
  9. self_sudo = self.sudo()
  10. self_sudo.sent = len(self_sudo.needaction_partner_ids) > 1 \
  11. or len(self_sudo.needaction_partner_ids) == 1 \
  12. and self_sudo.author_id \
  13. and self_sudo.needaction_partner_ids[0].id != self_sudo.author_id.id
  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')