I've got a wizard with it I want to create and download a file. The file will be gotten from a selection. It can be a qweb report, xml, xlst, ... .
When the button is clicked the method generates the selected file. I want it to pass to the browser for download. I know I can save the file in a binary field, but then the user needs to click on it, so I want to skip this step.
I know that I can download reports with
<button name="%(action_of_the_qweb_report)d" string="Get Document" type="action"/>
and from the odoo "website" when i get it from ir.attachments:
fileheaders = [ ('Content-Type', tmp_file[0].file_mimetype), ('Content-Length', len(downlaod_file)), ('Content-Disposition', 'attachment; filename="{}"'.format(tmp_file[0].name)) ] return request.make_response(downlaod_file, headers=fileheaders)
But I would like to do this from a odoo module. The problem is that files can be different types and some of them like xml are generated with python scripts.
So is there a way to just pass the file to the browser?
Hope this will get into: http://learnopenerp.blogspot.com/2020/06/write-binary-data-nto-zip-file-and-downlaod-it-on-button-click-in-odoo.html