Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
5637 Zobrazení

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

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit

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.

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
kvě 24
7272
1
čvc 23
2381
3
čvn 23
3266
4
čvn 22
4991
3
dub 22
5594