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.

29 lines
931 B

  1. # -*- coding: utf-8 -*-
  2. from openerp import api, models, fields
  3. class MailMailStats(models.Model):
  4. _inherit = 'mail.mail.statistics'
  5. partner_ids = fields.Many2many('res.partner', related='mail_mail_id.recipient_ids', string='Partners (Mail)')
  6. @api.one
  7. def _get_partner_id(self):
  8. if self.model == 'res.partner':
  9. self.partner_id = self.res_id
  10. else:
  11. self.partner_id = None
  12. partner_id = fields.Many2one('res.partner', compute=_get_partner_id, string='Partner (Document ID)')
  13. @api.one
  14. def _get_partners(self):
  15. res = {}
  16. for p in self.partner_ids:
  17. res[p.id] = p
  18. if self.partner_id and self.partner_id.id not in res:
  19. res[self.partner_id.id] = self.partner_id
  20. self.partners = ', '.join([('%s <%s>' % (p.name, p.email)) for id, p in res.items()])
  21. partners = fields.Char('Partners', compute=_get_partners)