diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index c526c0f1127..bdc968a333b 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -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))])