Skip to Content
Menú
This question has been flagged
2 Respostes
5642 Vistes

How we can show Log note i.e. internal log in opportunity will show in its customer chatter.

Avatar
Descartar
Best Answer

You need to override the "message_post" method in crm.lead object. When anything gets post in the chatter, this method gets called.

Override this method, call the super method first so that it will create the record of "mail.message" and return the recordset of the mail.message record. Now, copy the mail.message and pass the default dict in copy method (msg.copy({'res_id': self.partner_id.id, 'model': 'res.partner'})).

This will post the same message from Lead to related Partner.

Ex:

    @api.multi
@api.returns('mail.message', lambda value: value.id)
def message_post(self, body='', subject=None,
message_type='notification', subtype=None,
parent_id=False, attachments=None,
notif_layout=False, add_sign=True, model_description=False,
mail_auto_delete=True, **kwargs):
msg = super(CrmLead, self).message_post(body=body, subject=subject, message_type=message_type,
subtype=subtype, parent_id=parent_id, attachments=attachments,
notif_layout=notif_layout, add_sign=add_sign, model_description=model_description,
mail_auto_delete=mail_auto_delete, **kwargs)
if self.partner_id:
msg.copy(default={'res_id': self.partner_id.id, 'model': 'res.partner'})
return msg


Avatar
Descartar

Hi Sudhir,
I need to confirm, whether it will copy the log note posted in the crm.lead to the res.partner form? please confirm.
Thank You!!

Yes, it will copy the similar logs into the partner.

Best Answer

How can we show the callout log i.e. the content of the conversation with the customer will show up in the opportunity
I tried but no success

code: 

class CrmNote(models.Model):
_inherit = 'crm.lead'

@api.returns('mail.message', lambda value: value.id)
def message_post(self, body='', subject=None, message_type='notification', subtype_id=None, attachments=None, **kwargs):
msg = super(CrmNote, self).message_post(body='Crm: ' + body, subject=subject, message_type=message_type, subtype_id=subtype_id, attachments=attachments, **kwargs)
if self.partner_id:
msg.copy(default={'parent_id': 0, 'res_id': self.partner_id, 'model': 'res.partner'})
return msg


class PartnerNote(models.Model):
_inherit = 'res.partner'

@api.returns('mail.message', lambda value: value.id)
def message_post(self, body='', subject=None, message_type='notification', subtype_id=None, parent_id=False, attachments=None, **kwargs):
msg = super(PartnerNote, self).message_post(body='Partner: ' + body, subject=subject, message_type=message_type, subtype_id=subtype_id, parent_id=parent_id, attachments=attachments, **kwargs)
if self.id:
msg.copy(default={'res_id': 5, 'model': 'crm.lead'})
return msg

Avatar
Descartar
Related Posts Respostes Vistes Activitat
4
de maig 24
7275
1
de jul. 23
2384
3
de juny 23
3271
4
de juny 22
4995
3
d’abr. 22
5604