[FIX] some problem with reports python-side
bzr revid: nicolas.vanhoren@openerp.com-20120622140951-9iw406yvo6rvzfxs
This commit is contained in:
parent
bec922210e
commit
7df26eb3ec
|
@ -1814,15 +1814,20 @@ class Reports(View):
|
||||||
report = zlib.decompress(report)
|
report = zlib.decompress(report)
|
||||||
report_mimetype = self.TYPES_MAPPING.get(
|
report_mimetype = self.TYPES_MAPPING.get(
|
||||||
report_struct['format'], 'octet-stream')
|
report_struct['format'], 'octet-stream')
|
||||||
|
file_name = None
|
||||||
if 'name' not in action:
|
if 'name' not in action:
|
||||||
reports = req.session.model('ir.actions.report.xml')
|
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)
|
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,
|
return req.make_response(report,
|
||||||
headers=[
|
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-Type', report_mimetype),
|
||||||
('Content-Length', len(report))],
|
('Content-Length', len(report))],
|
||||||
cookies={'fileToken': int(token)})
|
cookies={'fileToken': int(token)})
|
||||||
|
|
Loading…
Reference in New Issue