Skip to content

Commit

Permalink
[FIX] base: backport of set mimetype on js and css assets
Browse files Browse the repository at this point in the history
On MS Windows, the mimetypes module relies on the Windows Registry to
guess mimetypes. As a consequence, when generating assets bundle for
javascript files, the mime type of js files may be wrong. In that
particular case, the Odoo user is facing an empty web page.
This commit enforce 'application/javascript' for js assets when they are
saved as ir_attachment in the database.

This commit is a backport of 77ca51f
  • Loading branch information
d-fence committed Dec 12, 2017
1 parent 6d02f7d commit 17c9208
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions odoo/addons/base/ir/ir_qweb/assetsbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,15 @@ def get_attachments(self, type):
return self.env['ir.attachment'].sudo().browse(attachment_ids)

def save_attachment(self, type, content, inc=None):
assert type in ('js', 'css')
ira = self.env['ir.attachment']

fname = '%s%s.%s' % (self.name, ('' if inc is None else '.%s' % inc), type)
mimetype = 'application/javascript' if type == 'js' else 'text/css'
values = {
'name': "/web/content/%s" % type,
'datas_fname': fname,
'mimetype' : mimetype,
'res_model': 'ir.ui.view',
'res_id': False,
'type': 'binary',
Expand Down

0 comments on commit 17c9208

Please sign in to comment.