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.

28 lines
1007 B

9 years ago
9 years ago
  1. # -*- coding: utf-8 -*-
  2. from openerp import api, models, fields
  3. class mail_message(models.Model):
  4. _inherit = 'mail.message'
  5. @api.one
  6. @api.depends('author_id', 'notified_partner_ids')
  7. def _get_sent(self):
  8. self_sudo = self.sudo()
  9. self_sudo.sent = len(self_sudo.notified_partner_ids) > 1 or len(self_sudo.notified_partner_ids) == 1 and self_sudo.author_id and self_sudo.notified_partner_ids[0].id != self_sudo.author_id.id
  10. sent = fields.Boolean('Sent', compute=_get_sent, help='Was message sent to someone', store=True)
  11. class mail_notification(models.Model):
  12. _inherit = 'mail.notification'
  13. def _notify(self, cr, uid, message_id, **kwargs):
  14. super(mail_notification, self)._notify(cr, uid, message_id, **kwargs)
  15. self.pool['mail.message'].browse(cr, uid, message_id)._get_sent()
  16. class mail_compose_message(models.TransientModel):
  17. _inherit = 'mail.compose.message'
  18. sent = fields.Boolean('Sent', help='dummy field to fix inherit error')