Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5632 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć

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.

Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
4
maj 24
7271
1
lip 23
2380
3
cze 23
3266
4
cze 22
4991
3
kwi 22
5593