diff options
| author | Atul Patel (OpenERP) <atp@tinyerp.com> | 2012-06-25 16:28:33 +0530 |
|---|---|---|
| committer | Atul Patel (OpenERP) <atp@tinyerp.com> | 2012-06-25 16:28:33 +0530 |
| commit | eaa3f47b92f82d9e032bd905bfdff9430fc957c5 (patch) | |
| tree | a068b92f1eac78a5934b0e25e5f240d1a710d8de /addons/mail/mail_thread.py | |
| parent | af8c698b46217d6aad7dc5d8f4b2027b93b9092f (diff) | |
| parent | 0a22debf5fb7af0dbf4ebf5039aa6ecbfb054a95 (diff) | |
[MERGE]: Merged with lp:openobject-addons
bzr revid: atp@tinyerp.com-20120625105833-yx7rn4ggvbiwpmlc
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 |
