Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
5633 Vistas

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

Avatar
Descartar
Mejor respuesta

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.

Mejor respuesta

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
Publicaciones relacionadas Respuestas Vistas Actividad
4
may 24
7271
1
jul 23
2380
3
jun 23
3266
4
jun 22
4991
3
abr 22
5593