diff options
| author | Arnaud Pineux <api@openerp.com> | 2012-12-11 16:33:52 +0100 |
|---|---|---|
| committer | Arnaud Pineux <api@openerp.com> | 2012-12-11 16:33:52 +0100 |
| commit | d288b45bb3e192146dfd2fe40d840c8c23a79f74 (patch) | |
| tree | 55f0fed474aee380ecd2d6a544024763bd533a20 /addons/mail/controllers/main.py | |
| parent | dd94a6b00a129c506299ec7e0b5739f5e9668a24 (diff) | |
| parent | c70f05cc778435a069d258a82b8b2870e8565922 (diff) | |
[MERGE] with trunk
bzr revid: api@openerp.com-20121211153352-l1ikpqgz8cxmuuu0
Diffstat (limited to 'addons/mail/controllers/main.py')
| -rw-r--r-- | addons/mail/controllers/main.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py new file mode 100644 index 00000000000..4c6f6e56064 --- /dev/null +++ b/addons/mail/controllers/main.py @@ -0,0 +1,22 @@ +import base64 +import openerp.addons.web.http as oeweb +from openerp.addons.web.controllers.main import content_disposition + +#---------------------------------------------------------- +# Controller +#---------------------------------------------------------- +class MailController(oeweb.Controller): + _cp_path = '/mail' + + @oeweb.httprequest + def download_attachment(self, req, model, id, method, attachment_id, **kw): + Model = req.session.model(model) + res = getattr(Model, method)(int(id), int(attachment_id)) + if res: + filecontent = base64.b64decode(res.get('base64')) + filename = res.get('filename') + if filecontent and filename: + return req.make_response(filecontent, + headers=[('Content-Type', 'application/octet-stream'), + ('Content-Disposition', content_disposition(filename, req))]) + return req.not_found() |
