Skip to content

Instantly share code, notes, and snippets.

@oerp-odoo
Last active January 11, 2018 09:25
Show Gist options
  • Save oerp-odoo/59b506ce4372916a3c39fb7d5c9ac930 to your computer and use it in GitHub Desktop.
Save oerp-odoo/59b506ce4372916a3c39fb7d5c9ac930 to your computer and use it in GitHub Desktop.
@http.route('/web/excel.report/xls', type='http', auth="user")
def download_xls_report(self, model, id):
"""Handle download for XLS reports."""
# Prepare report wizard
Model = request.registry[model]
cr, uid, context = request.cr, request.uid, request.context
id = int(id)
wizard = Model.browse(cr, uid, id, context=context)
# Get filename
filename = wizard.get_filename()
# Download
return request.make_response(
(wizard.data),
headers=[('Content-Disposition', content_disposition(filename)),
('Content-Type', 'application/vnd.ms-excel')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment