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.

41 lines
1.2 KiB

  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.multi
  7. def _get_partner_id(self):
  8. for r in self:
  9. r._get_partner_id_one(self)
  10. @api.multi
  11. def _get_partner_id_one(self):
  12. self.ensure_one()
  13. if self.model == 'res.partner':
  14. self.partner_id = self.res_id
  15. else:
  16. self.partner_id = None
  17. partner_id = fields.Many2one('res.partner', compute=_get_partner_id, string='Partner (Document ID)')
  18. @api.multi
  19. def _get_partners(self):
  20. for r in self:
  21. r._get_partners_one(self)
  22. @api.multi
  23. def _get_partners_one(self):
  24. self.ensure_one()
  25. res = {}
  26. for p in self.partner_ids:
  27. res[p.id] = p
  28. if self.partner_id and self.partner_id.id not in res:
  29. res[self.partner_id.id] = self.partner_id
  30. self.partners = ', '.join([('%s <%s>' % (p.name, p.email)) for id, p in res.items()])
  31. partners = fields.Char('Partners', compute=_get_partners)