diff --git a/addons/mail/ir_attachment.py b/addons/mail/ir_attachment.py index 99c5a9e054e..a5d8705c0fb 100644 --- a/addons/mail/ir_attachment.py +++ b/addons/mail/ir_attachment.py @@ -186,12 +186,11 @@ class IrAttachment(osv.Model): def get_attachment_type(self, cr, uid, ids, name, args, context=None): result = {} for attachment in self.browse(cr, uid, ids, context=context): - fileext = os.path.splitext(attachment.datas_fname)[1].lower() - if not fileext or not fileext[1:] in self._fileext_to_type: - return 'unknown' - result[attachment.id] = self._fileext_to_type[fileext[1:]] + fileext = os.path.splitext(attachment.datas_fname or '')[1].lower()[1:] + result[attachment.id] = self._fileext_to_type.get(fileext, 'unknown') return result _columns = { - 'file_type': fields.function(get_attachment_type, type='char', string='File Type'), + 'file_type_icon': fields.function(get_attachment_type, type='char', string='File Type Icon'), + 'file_type': fields.related('file_type_icon', type='char'), # FIXME remove in trunk } diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 40a51df91d2..4c05d7a6d1f 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -351,12 +351,12 @@ class mail_message(osv.Model): partner_tree = dict((partner[0], partner) for partner in partners) # 2. Attachments as SUPERUSER, because could receive msg and attachments for doc uid cannot see - attachments = ir_attachment_obj.read(cr, SUPERUSER_ID, list(attachment_ids), ['id', 'datas_fname', 'name', 'file_type'], context=context) + attachments = ir_attachment_obj.read(cr, SUPERUSER_ID, list(attachment_ids), ['id', 'datas_fname', 'name', 'file_type_icon'], context=context) attachments_tree = dict((attachment['id'], { 'id': attachment['id'], 'filename': attachment['datas_fname'], 'name': attachment['name'], - 'file_type': attachment['file_type'], + 'file_type_icon': attachment['file_type_icon'], }) for attachment in attachments) # 3. Update message dictionaries diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 6ce588e82a2..28cbbca1f2c 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -88,10 +88,10 @@ --> - +
- +
[
@@ -100,7 +100,7 @@
- +