[IMP] web: move controler download_attachment into mail.

bzr revid: chm@openerp.com-20121211145343-jhjj9sohn2shkbt9
This commit is contained in:
Christophe Matthieu
2012-12-11 15:53:43 +01:00
parent 295c36e66c
commit 6c73d8dff8
4 changed files with 27 additions and 1 deletions
+1
View File
@@ -35,5 +35,6 @@ import wizard
import res_config
import mail_group_menu
import update
import controllers
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+3
View File
@@ -0,0 +1,3 @@
import main
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
+22
View File
@@ -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()
+1 -1
View File
@@ -30,7 +30,7 @@ openerp.mail = function (session) {
/* Get the url of an attachment {'id': id} */
get_attachment_url: function (session, message_id, attachment_id) {
return session.url('/web/binary/download_attachment', {
return session.url('/mail/download_attachment', {
'model': 'mail.message',
'id': message_id,
'method': 'download_attachment',