leading to potential issues.
Now the behavior is back to its previous version, posting on the user creates a private
discussion. Fixed management of model variable in message_post to avoid posting messages
on the mail.thread model.
Classic inbox writes on partner, with hr it writes on the employee profile, like previously.
# set in the context.
model = False
if thread_id:
- model = context.get('thread_model', self._name) if self._name == 'mail.thread' else self._name
- if model != self._name and hasattr(self.pool[model], 'message_post'):
+ model = context.get('thread_model', False) if self._name == 'mail.thread' else self._name
+ if model and model != self._name and hasattr(self.pool[model], 'message_post'):
del context['thread_model']
return self.pool[model].message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs)
self.message_subscribe(cr, uid, [thread_id], list(partner_to_subscribe), context=context)
# _mail_flat_thread: automatically set free messages to the first posted message
- if self._mail_flat_thread and not parent_id and thread_id:
+ if self._mail_flat_thread and model and not parent_id and thread_id:
message_ids = mail_message.search(cr, uid, ['&', ('res_id', '=', thread_id), ('model', '=', model)], context=context, order="id ASC", limit=1)
parent_id = message_ids and message_ids[0] or False
# we want to set a parent: force to set the parent_id to the oldest ancestor, to avoid having more than 1 level of thread
values.update({
'author_id': author_id,
'model': model,
- 'res_id': thread_id or False,
+ 'res_id': model and thread_id or False,
'body': body,
'subject': subject or False,
'type': type,
# done with SUPERUSER_ID, because on some models users can post only with read access, not necessarily write access
self.write(cr, SUPERUSER_ID, [thread_id], {'message_last_post': fields.datetime.now()}, context=context)
message = mail_message.browse(cr, uid, msg_id, context=context)
- if message.author_id and thread_id and type != 'notification' and not context.get('mail_create_nosubscribe'):
+ if message.author_id and model and thread_id and type != 'notification' and not context.get('mail_create_nosubscribe'):
self.message_subscribe(cr, uid, [thread_id], [message.author_id.id], context=context)
return msg_id
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
+ 'thread_model': 'res.partner',
'needaction_menu_ref': ['mail.mail_tomefeeds', 'mail.mail_starfeeds']
}</field>
<field name="params" eval=""{
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
+ 'thread_model': 'res.partner',
'search_default_message_unread': True,
'needaction_menu_ref': ['mail.mail_starfeeds', 'mail.mail_inboxfeeds']
}</field>
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
+ 'thread_model': 'res.partner',
'search_default_message_unread': True
}</field>
<field name="params" eval=""{
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
+ 'thread_model': 'res.partner',
'needaction_menu_ref': ['mail.mail_tomefeeds', 'mail.mail_starfeeds', 'mail.mail_inboxfeeds']
}</field>
<field name="params" eval=""{
@api.cr_uid_ids_context
def message_post(self, cr, uid, thread_id, context=None, **kwargs):
- """ Redirect the posting of message on res.users to the related partner.
+ """ Redirect the posting of message on res.users as a private discussion.
This is done because when giving the context of Chatter on the
various mailboxes, we do not have access to the current partner_id. """
if isinstance(thread_id, (list, tuple)):
if user_pid not in current_pids:
partner_ids.append(user_pid)
kwargs['partner_ids'] = partner_ids
- return self.pool['res.partner'].message_post(cr, uid, user_pid, **kwargs)
+ if context and context.get('thread_model') == 'res.partner':
+ return self.pool['res.partner'].message_post(cr, uid, user_pid, **kwargs)
+ return self.pool['mail.thread'].message_post(cr, uid, uid, **kwargs)
def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None):
return True
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
+ 'thread_model': 'res.partner',
}</field>
<field name="params" eval=""{
'domain': [
<field name="context">{
'default_model': 'res.users',
'default_res_id': uid,
+ 'thread_model': 'res.partner',
'search_default_message_unread': True
}</field>
<field name="params" eval=""{
<field name="tag">mail.wall</field>
<field name="context">{
'default_model': 'res.users',
- 'default_res_id': uid
+ 'default_res_id': uid,
+ 'thread_model': 'res.partner',
}</field>
<field name="params" eval=""{
'domain': [