[FIX] base: fetch mimetype on ir.attachment for binary fields
This commit is contained in:
@@ -300,6 +300,10 @@ class ir_http(osv.AbstractModel):
|
||||
mimetype = obj.mimetype
|
||||
elif filename:
|
||||
mimetype = mimetypes.guess_type(filename)[0]
|
||||
elif getattr(env[model]._fields[field], 'attachment', False):
|
||||
# for binary fields, fetch the ir_attachement for mimetype check
|
||||
attach_mimetype = env['ir.attachment'].search_read(domain=[('res_model', '=', model), ('res_id', '=', id), ('res_field', '=', field)], fields=['mimetype'], limit=1)
|
||||
mimetype = attach_mimetype and attach_mimetype[0]['mimetype']
|
||||
if not mimetype:
|
||||
mimetype = default_mimetype
|
||||
headers.append(('Content-Type', mimetype))
|
||||
|
||||
Reference in New Issue
Block a user