diff --git a/models.py b/models.py index 0d8c4d6..1fc804f 100644 --- a/models.py +++ b/models.py @@ -4,13 +4,25 @@ class MailMailStats(models.Model): _inherit = 'mail.mail.statistics' - partner_ids = fields.Many2many('res.partner', related='mail_mail_id.recipient_ids', string='Partners') + partner_ids = fields.Many2many('res.partner', related='mail_mail_id.recipient_ids', string='Partners (Mail)') @api.one - def _get_partner_ids_text(self): - res = [] + def _get_partner_id(self): + if self.model=='res.partner': + self.partner_id = self.res_id + else: + self.partner_id = None + + partner_id = fields.Many2one('res.partner', compute=_get_partner_id, string='Partner (Document ID)') + + @api.one + def _get_partners(self): + res = {} for p in self.partner_ids: - res.append('%s <%s>' % (p.name, p.email)) - self.partner_ids_text = ', '.join(res) + res[p.id] = p + if self.partner_id and self.partner_id.id not in res: + res[self.partner_id.id] = self.partner_id + self.partners = ', '.join([('%s <%s>' % (p.name, p.email)) for id,p in res.items()]) + - partner_ids_text = fields.Char('Partners', compute=_get_partner_ids_text) + partners = fields.Char('Partners', compute=_get_partners) diff --git a/views.xml b/views.xml index 34a67a8..19362b4 100644 --- a/views.xml +++ b/views.xml @@ -10,6 +10,12 @@ + + + @@ -23,7 +29,7 @@ - +