From 7df26eb3eccae03b48fadc31d7297714cebf3435 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 22 Jun 2012 16:09:51 +0200 Subject: [PATCH] [FIX] some problem with reports python-side bzr revid: nicolas.vanhoren@openerp.com-20120622140951-9iw406yvo6rvzfxs --- addons/web/controllers/main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 3526883e45e..546a232ef3d 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1814,15 +1814,20 @@ class Reports(View): report = zlib.decompress(report) report_mimetype = self.TYPES_MAPPING.get( report_struct['format'], 'octet-stream') + file_name = None if 'name' not in action: reports = req.session.model('ir.actions.report.xml') - res_id = reports.search([('report_name', '=',action['report_name']),], + res_id = reports.search([('report_name', '=', action['report_name']),], 0, False, False, context) - action['name'] = reports.read(res_id, ['name'], context)[0]['name'] + if len(res_id) > 0: + file_name = reports.read(res_id[0], ['name'], context)['name'] + else: + file_name = action['report_name'] return req.make_response(report, headers=[ - ('Content-Disposition', 'attachment; filename="%s.%s"' % (action['name'], report_struct['format'])), + # maybe we should take of what characters can appear in a file name? + ('Content-Disposition', 'attachment; filename="%s.%s"' % (file_name, report_struct['format'])), ('Content-Type', report_mimetype), ('Content-Length', len(report))], cookies={'fileToken': int(token)})