Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
5628 Tampilan

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

Avatar
Buang
Jawaban Terbai

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
Buang

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.

Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
4
Mei 24
7268
1
Jul 23
2379
3
Jun 23
3265
4
Jun 22
4991
3
Apr 22
5591