[IMP] mail_message_copy_in_partner:

new message is a note without recipients
This commit is contained in:
clementthomas
2024-06-27 14:58:10 +02:00
parent 5312b8383f
commit 47f27480ee
2 changed files with 13 additions and 2 deletions

View File

@@ -18,6 +18,7 @@
mail_message_copy_in_partner
=================
If current model has partner_id field, all messages will be copied in partner's chatter
New message is a note without recipients
Installation

View File

@@ -8,7 +8,17 @@ class MailThread(models.AbstractModel):
def message_post(self, body='', **kwargs):
#send message to related partner
if hasattr(self, 'partner_id') and self.partner_id:
msg = _('<b>[%(object)s]</b> %(body)s',object=self._get_html_link(), body=body)
self.partner_id.message_post(body=msg, **kwargs)
msg = _('<b>[%(object)s]</b> %(body)s',object=self._get_html_link(), body=body)
new_kwargs = kwargs.copy()
#new message is a note
new_kwargs['subtype_xmlid'] = "mail.mt_note"
#do not send anything
new_kwargs['partner_ids'] = []
self.partner_id.message_post(body=msg, **new_kwargs)
return super(MailThread, self).message_post(body=body, **kwargs)