diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-10-14 21:25:42 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-10-26 11:43:36 +0100 |
| commit | 63392cc239c50c328becbc36c013120f1e68426b (patch) | |
| tree | 891ccba7096a6bcec3d1942e43798885eb236cb1 /addons/web/controllers/main.py | |
| parent | 890f1302c7175e24887e66a2f8b973e72fb4c7e9 (diff) | |
[FIX] web: can use web/image controller for attachment type url
Attachment type url return a status 301 for response
Diffstat (limited to 'addons/web/controllers/main.py')
| -rw-r--r-- | addons/web/controllers/main.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index d90e86c34d4..5e87d40cac5 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -506,7 +506,11 @@ def binary_content(xmlid=None, model='ir.attachment', id=None, field='datas', un headers.append(('Content-Disposition', content_disposition(filename))) # get content after cache control - content = obj[field] or '' + if model == 'ir.attachment' and obj.type == 'url' and obj.url: + status = 301 + content = obj.url + else: + content = obj[field] or '' return (status, headers, content) @@ -1043,6 +1047,8 @@ class Binary(http.Controller): status, headers, content = binary_content(xmlid=xmlid, model=model, id=id, field=field, unique=unique, filename=filename, filename_field=filename_field, download=download, mimetype=mimetype) if status == 304: response = werkzeug.wrappers.Response(status=status, headers=headers) + elif status == 301: + return werkzeug.utils.redirect(content, code=301) elif status != 200: response = request.not_found() else: @@ -1074,6 +1080,8 @@ class Binary(http.Controller): status, headers, content = binary_content(xmlid=xmlid, model=model, id=id, field=field, unique=unique, filename=filename, filename_field=filename_field, download=download, mimetype=mimetype, default_mimetype='image/png') if status == 304: return werkzeug.wrappers.Response(status=304, headers=headers) + elif status == 301: + return werkzeug.utils.redirect(content, code=301) elif status != 200 and download: return request.not_found() |
