[FIX] mail: message_read: ancestor_id is set in thread mode as the first displayed ancestor; ancestor_id is set to parent_id parameter in flat mode.

bzr revid: tde@openerp.com-20121023132755-dp29bake9eux5vz7
This commit is contained in:
Thibault Delavallée 2012-10-23 15:27:55 +02:00
parent 7bae2a58fe
commit b4bcff666a
1 changed files with 8 additions and 3 deletions

View File

@ -368,8 +368,10 @@ class mail_message(osv.Model):
:param list domain: optional domain for searching ids if ids not set
:param list message_unload_ids: optional ids we do not want to fetch,
because i.e. they are already displayed somewhere
:param int parent_id: if parent_id reached when adding ancestors,
stop going further in the ancestor search
:param int parent_id: context of parent_id
- if parent_id reached when adding ancestors, stop going further
in the ancestor search
- if set in flat mode, ancestor_id is set to parent_id
:param int limit: number of messages to fetch, before adding the
ancestors and expandables
:return list: list of message structure for the Chatter widget
@ -400,13 +402,16 @@ class mail_message(osv.Model):
message_list.append(self._message_get_dict(cr, uid, message, context=context))
# get the older ancestor the user can read, update its ancestor field
if not thread_level:
message_list[-1]['ancestor_id'] = parent_id
continue
parent = self._get_parent(cr, uid, message, context=context)
while parent and parent.get('id') != parent_id:
message_list[-1]['ancestor_id'] = parent.get('id')
message = parent
parent = self._get_parent(cr, uid, message, context=context)
# if in thread: add its ancestor to the list of messages
if thread_level and not read_messages.get(message.get('id')) and message.get('id') not in message_unload_ids:
if not read_messages.get(message.get('id')) and message.get('id') not in message_unload_ids:
read_messages[message.get('id')] = message
message_list.append(self._message_get_dict(cr, uid, message, context=context))