[IMP] web: move controler download_attachment into mail.
bzr revid: chm@openerp.com-20121211145343-jhjj9sohn2shkbt9
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import main
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -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()
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user