From e13a97446a56aeb8745ff1563edbc0b7f73f9c70 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 8 Sep 2011 09:14:15 +0200 Subject: [PATCH] [FIX] reports: report_type may be missing from the action descriptor, don't rely on it being there bzr revid: xmo@openerp.com-20110908071415-9gdyvkpwq7i7fxob --- addons/web/controllers/main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index e302f721fc7..647c6155018 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1362,13 +1362,15 @@ class Reports(View): context = req.session.eval_context( openerpweb.nonliterals.CompoundContext( req.context or {}, action[ "context"])) + + report_data = {"id": context["active_id"], "model": context["active_model"]} + if 'report_type' in action: + report_data['report_type'] = action['report_type'] report_id = report_srv.report( req.session._db, req.session._uid, req.session._password, action["report_name"], context["active_ids"], - {"id": context["active_id"], - "model": context["active_model"], - "report_type": action["report_type"]}, - context) + report_data, context) + report_struct = None while True: report_struct = report_srv.report_get( @@ -1384,7 +1386,7 @@ class Reports(View): report_struct['format'], 'octet-stream') return req.make_response(report, headers=[ - ('Content-Disposition', 'attachment; filename="%s.%s"' % (action['report_name'], action['report_type'])), + ('Content-Disposition', 'attachment; filename="%s.%s"' % (action['report_name'], report_struct['format'])), ('Content-Type', report_mimetype), ('Content-Length', len(report))], cookies={'fileToken': int(token)})