diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-01-10 16:50:20 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-01-10 16:50:20 +0100 |
| commit | d54a19681110663aa8016f73b70c1663cc2a2b10 (patch) | |
| tree | b4b6af6dde978be2345a171687069968c4163cb7 /addons | |
| parent | d98b8b8be0145700667c0f4cc0e7619dec790c5b (diff) | |
[IMP] correctly handle filenames in list view binaries
bzr revid: xmo@openerp.com-20120110155020-ab02qb0ktlfxnwvb
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/web/controllers/main.py | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/formats.js | 15 |
2 files changed, 12 insertions, 5 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index c775927a8cc..b6405873f80 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1217,7 +1217,7 @@ class Binary(openerpweb.Controller): filename = res.get(filename_field, '') or filename return req.make_response(filecontent, [('Content-Type', 'application/octet-stream'), - ('Content-Disposition', 'attachment; filename=' + filename)]) + ('Content-Disposition', 'attachment; filename="%s"' % filename)]) @openerpweb.httprequest def upload(self, req, callback, ufile): diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 4076c190a74..819301f9e55 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -289,11 +289,18 @@ openerp.web.format_cell = function (row_data, column, options) { return _.str.sprintf('<input type="checkbox" %s disabled="disabled"/>', row_data[column.id].value ? 'checked="checked"' : ''); case "binary": + var text = _t("Download"), + download_url = _.str.sprintf('/web/binary/saveas?session_id=%s&model=%s&field=%s&id=%d', openerp.connection.session_id, options.model, column.id, options.id); + if (column.filename) { + download_url += '&filename_field=' + column.filename; + if (row_data[column.filename]) { + text = _.str.sprintf(_t("Download \"%s\""), openerp.web.format_value( + row_data[column.filename].value, {type: 'char'})); + } + } return _.str.sprintf('<a href="%(href)s">%(text)s</a> (%(size)s)', { - text: _t("Download"), - href: _.str.sprintf('/web/binary/saveas?session_id=%s&model=%s&field=%s&id=%d', - openerp.connection.session_id, options.model, - column.id, options.id), + text: text, + href: download_url, size: row_data[column.id].value }); } |
