diff options
| author | Purnendu Singh (OpenERP) <psi@tinyerp.com> | 2012-06-22 11:22:30 +0530 |
|---|---|---|
| committer | Purnendu Singh (OpenERP) <psi@tinyerp.com> | 2012-06-22 11:22:30 +0530 |
| commit | 1c35eb1049da4e5c4e4e1e9c50be018405806c08 (patch) | |
| tree | a2230a93b6c7126df352d87bbaff801970dca468 /addons/mail/mail_thread.py | |
| parent | 4dbe82473921a2335dce292f9b70ef2a8bab3858 (diff) | |
| parent | eea8d596041e8f6ca3fd1d31ef3a5c5d4ae6e91d (diff) | |
[MERGE] Mearge with main addons
bzr revid: psi@tinyerp.com-20120622055230-trqmxu7r1qtxa0ut
Diffstat (limited to 'addons/mail/mail_thread.py')
| -rw-r--r-- | addons/mail/mail_thread.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b1b6c68e4cc..0f404155f42 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -413,7 +413,30 @@ class mail_thread(osv.osv): """ OpenChatter feature: return thread messages """ msg_ids = self.message_load_ids(cr, uid, ids, limit, offset, domain, ascent, root_ids, context=context) - msgs = self.pool.get('mail.message').read(cr, uid, msg_ids, context=context) + msgs = self.pool.get('mail.message').read(cr, uid, msg_ids, [], context=context) + + """ Retrieve all attachments names """ + map_id_to_name = {} + + for msg in msgs: + for attach_id in msg["attachment_ids"]: + map_id_to_name[attach_id] = '' # use empty string as a placeholder + + ids = map_id_to_name.keys() + names = self.pool.get('ir.attachment').name_get(cr, uid, ids, context=context) + + # convert the list of tuples into a dictionnary + for name in names: + map_id_to_name[name[0]] = name[1] + + # give corresponding ids and names to each message + for msg in msgs: + msg["attachments"] = [] + + for attach_id in msg["attachment_ids"]: + msg["attachments"].append({'id': attach_id, 'name': map_id_to_name[attach_id]}) + + """ Sort and return messages """ msgs = sorted(msgs, key=lambda d: (-d['id'])) return msgs |
