[FIX] #1526 - Missing filename on binary fields download

This commit is contained in:
blaggacao 2014-08-15 22:26:38 -05:00
parent 25e11113b5
commit 1737ae3dd6
1 changed files with 7 additions and 2 deletions

View File

@ -1090,9 +1090,14 @@ class Binary(http.Controller):
if not filecontent:
return request.not_found()
else:
filename = '%s_%s' % (model.replace('.', '_'), id)
if filename_field:
filename = res.get(filename_field, '') or filename
filename = res.get(filename_field, '')
if not filename:
# based on https://bugs.launchpad.net/openerp-web/+bug/1252458
filename_name = Model.read([int(id)], [filename_field], context)
filename = filename_name and filename_name[0] and filename_name[0][filename_field] or False
if not filename:
filename = '%s_%s' % (model.replace('.', '_'), id)
return request.make_response(filecontent,
[('Content-Type', 'application/octet-stream'),
('Content-Disposition', content_disposition(filename))])