Browse Source

[IMP] get partner from Document ID

pull/1/head
Ivan Yelizariev 10 years ago
parent
commit
4bd3f0502e
  1. 24
      models.py
  2. 8
      views.xml

24
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)

8
views.xml

@ -10,6 +10,12 @@
<xpath expr="//form" position="inside">
<notebook>
<page string="Partners">
<group>
<label for="partners" string="Partners (summary)"/>
<field name="partners" readonly="1" nolabel="1"/>
<field name="partner_id" readonly="1"/>
</group>
<label for="partner_ids"/>
<field name="partner_ids" readonly="1"/>
</page>
</notebook>
@ -23,7 +29,7 @@
<field name="inherit_id" ref="mass_mailing.view_mail_mail_statistics_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='mail_mail_id_int']" position="before">
<field name="partner_ids_text"/>
<field name="partners"/>
</xpath>
</field>
</record>

Loading…
Cancel
Save