Skip to Content
Menu
This question has been flagged
1 Reply
3367 Views

I use a method to generate a report in xlsx format using xlsxwriter. I want to know if there is a way to download the binary data returned by the method by clicking a button on the view?

I can create the report and save it on the server's hard drive but I don't want to do that, I want the user to be able download the binary data and store it as a file on his hard drive.

I use xlsxwriter because Base report xlsx doesn't work on Odoo 12.

Avatar
Discard
Best Answer

Hi,

you can return the url action of the created attachment:

        action = {
            'type': 'ir.actions.act_url',
            'url': '/web/content/{}?download=true'.format(attachment_id.id,),
            'target': 'self',
        }
        return action

It will start the immediate download of the file. However, the attachment should be anyway created (you can remove if afterwards)

Avatar
Discard