Skip to content

Commit

Permalink
[FIX] mail: set the parent_id to the first message of type email
Browse files Browse the repository at this point in the history
And fallback of any type if there is none of type email

This fix allow the communication between two mail thread from two different Odoo servers having message creation subtypes, like project issue or crm lead
  • Loading branch information
beledouxdenis committed Oct 16, 2014
1 parent 9c0e8f1 commit 1d57a09
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/mail/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,9 @@ def message_post(self, cr, uid, thread_id, body='', subject=None, type='notifica

# _mail_flat_thread: automatically set free messages to the first posted message
if self._mail_flat_thread 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)
message_ids = mail_message.search(cr, uid, ['&', ('res_id', '=', thread_id), ('model', '=', model), ('type', '=', 'email')], context=context, order="id ASC", limit=1)
if not message_ids:
message_ids = 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
elif parent_id:
Expand Down

0 comments on commit 1d57a09

Please sign in to comment.