[FIX] mail,website_sale: rename file_type to file_type_icon to avoid name conflict with file_type field added by document module
bzr revid: chs@openerp.com-20140228142233-i0mm9lav0czbydkk
This commit is contained in:
parent
4954c0fa39
commit
47c4728f43
|
@ -186,12 +186,11 @@ class IrAttachment(osv.Model):
|
||||||
def get_attachment_type(self, cr, uid, ids, name, args, context=None):
|
def get_attachment_type(self, cr, uid, ids, name, args, context=None):
|
||||||
result = {}
|
result = {}
|
||||||
for attachment in self.browse(cr, uid, ids, context=context):
|
for attachment in self.browse(cr, uid, ids, context=context):
|
||||||
fileext = os.path.splitext(attachment.datas_fname)[1].lower()
|
fileext = os.path.splitext(attachment.datas_fname or '')[1].lower()[1:]
|
||||||
if not fileext or not fileext[1:] in self._fileext_to_type:
|
result[attachment.id] = self._fileext_to_type.get(fileext, 'unknown')
|
||||||
return 'unknown'
|
|
||||||
result[attachment.id] = self._fileext_to_type[fileext[1:]]
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
_columns = {
|
_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
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,12 +351,12 @@ class mail_message(osv.Model):
|
||||||
partner_tree = dict((partner[0], partner) for partner in partners)
|
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
|
# 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'], {
|
attachments_tree = dict((attachment['id'], {
|
||||||
'id': attachment['id'],
|
'id': attachment['id'],
|
||||||
'filename': attachment['datas_fname'],
|
'filename': attachment['datas_fname'],
|
||||||
'name': attachment['name'],
|
'name': attachment['name'],
|
||||||
'file_type': attachment['file_type'],
|
'file_type_icon': attachment['file_type_icon'],
|
||||||
}) for attachment in attachments)
|
}) for attachment in attachments)
|
||||||
|
|
||||||
# 3. Update message dictionaries
|
# 3. Update message dictionaries
|
||||||
|
|
|
@ -88,10 +88,10 @@
|
||||||
-->
|
-->
|
||||||
<t t-name="mail.thread.message.attachments">
|
<t t-name="mail.thread.message.attachments">
|
||||||
<t t-foreach='widget.attachment_ids' t-as='attachment'>
|
<t t-foreach='widget.attachment_ids' t-as='attachment'>
|
||||||
<t t-if="attachment.file_type !== 'webimage'">
|
<t t-if="attachment.file_type_icon !== 'webimage'">
|
||||||
<div t-attf-class="oe_attachment #{attachment.upload ? 'oe_uploading' : ''}">
|
<div t-attf-class="oe_attachment #{attachment.upload ? 'oe_uploading' : ''}">
|
||||||
<a t-att-href='attachment.url' target="_blank">
|
<a t-att-href='attachment.url' target="_blank">
|
||||||
<img t-att-src="'/mail/static/src/img/mimetypes/' + attachment.file_type + '.png'"></img>
|
<img t-att-src="'/mail/static/src/img/mimetypes/' + attachment.file_type_icon + '.png'"></img>
|
||||||
<div class='oe_name'><t t-raw='attachment.name' /></div>
|
<div class='oe_name'><t t-raw='attachment.name' /></div>
|
||||||
</a>
|
</a>
|
||||||
<div class='oe_delete oe_e' title="Delete this attachment" t-att-data-id="attachment.id">[</div>
|
<div class='oe_delete oe_e' title="Delete this attachment" t-att-data-id="attachment.id">[</div>
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="attachment.file_type === 'webimage'">
|
<t t-if="attachment.file_type_icon === 'webimage'">
|
||||||
<div t-attf-class="oe_attachment oe_preview #{attachment.upload ? 'oe_uploading' : ''}">
|
<div t-attf-class="oe_attachment oe_preview #{attachment.upload ? 'oe_uploading' : ''}">
|
||||||
<a t-att-href='attachment.url' target="_blank">
|
<a t-att-href='attachment.url' target="_blank">
|
||||||
<img t-att-src="widget.attachments_resize_image(attachment.id, [100,80])"></img>
|
<img t-att-src="widget.attachments_resize_image(attachment.id, [100,80])"></img>
|
||||||
|
|
|
@ -419,11 +419,11 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="oe_msg_attachment" t-foreach='message.attachment_ids' t-as='attachment'>
|
<div class="oe_msg_attachment" t-foreach='message.attachment_ids' t-as='attachment'>
|
||||||
<a t-att-href="'/mail/download_attachment?model=mail.message&id='+str(message.id)+'&method=download_attachment&attachment_id='+str(attachment.id)" target="_blank">
|
<a t-att-href="'/mail/download_attachment?model=mail.message&id='+str(message.id)+'&method=download_attachment&attachment_id='+str(attachment.id)" target="_blank">
|
||||||
<t t-if="attachment.file_type == 'webimage'">
|
<t t-if="attachment.file_type_icon == 'webimage'">
|
||||||
<img t-att-src="'/web/binary/image?model=ir.attachment&field=datas&id=' + str(attachment.id) + '&resize=100,80'"
|
<img t-att-src="'/web/binary/image?model=ir.attachment&field=datas&id=' + str(attachment.id) + '&resize=100,80'"
|
||||||
class='oe_attachment_embedded'></img>
|
class='oe_attachment_embedded'></img>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="attachment.file_type != 'webimage'">
|
<t t-if="attachment.file_type_icon != 'webimage'">
|
||||||
<img t-att-src="'/mail/static/src/img/mimetypes/' + attachment.file_type + '.png'"
|
<img t-att-src="'/mail/static/src/img/mimetypes/' + attachment.file_type + '.png'"
|
||||||
class='oe_attachment_webimage'></img>
|
class='oe_attachment_webimage'></img>
|
||||||
</t>
|
</t>
|
||||||
|
|
Loading…
Reference in New Issue