From: niv-openerp Date: Fri, 22 Jun 2012 14:09:51 +0000 (+0200) Subject: [FIX] some problem with reports python-side X-Git-Tag: 7.0-server~669^2~26 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=7df26eb3eccae03b48fadc31d7297714cebf3435;hp=bec922210e4e33914ea9a8d02aa4b7c440ac5906;p=odoo%2Fodoo.git [FIX] some problem with reports python-side bzr revid: nicolas.vanhoren@openerp.com-20120622140951-9iw406yvo6rvzfxs --- diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 3526883..546a232 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)})