Odoo Help


How to download .xls file in a single click?

on 8/27/14, 5:22 PM 4,412 views

Hello, I am generating a .xls file with xlwt python-package and writing generated .xls in a binary field. To see that .xls I need to click on binary field then it gives me file to download and after download I can open.  I want to omit this step of clicking binary to download file.

I would prefer to click on "Generate Excel" button and it should show me dialogue box to download file. ( without clicking the binary field where file is being saved)

Thanks in advance , any help would be appreciated!!

Hi, Did you manage to resolve? I have the same issue and not able to find an answer. Many thanks,

Mihai Marius
on 10/5/15, 3:39 AM

Yes, I managed to do ,I am out will post answer as soon as I get back to computer.

on 10/5/15, 7:00 AM


Please have a look on the complete blog "How to Download any File on Button Click".

I am sure that it will help a lot.


ameer ashraf
On 12/29/15, 3:37 AM

 Hello, u managed to solve this problem? kindly share with me how u solved it. i had the same problem but still did not able to solve it. thank you.

Akhil P Sivan
On 10/5/15, 4:22 AM

Hi, this is one more option. On clicking the "Generate Excel" button, you can open a wizard, which contains a button "print xls" (and possibly some entries to pass to the report parser if needed), on that button call a python method, which is defined on the transient model, for eg:

- this is my button on wizard:

<button icon="gtk-execute" name="get_report" string="Export xls" type="object" context="{'xls_export':1}"/>;

- the method in transient model, in my case I have both pdf or excel report, thats why am passing context in button:

def get_report(self, cr, uid, ids, context=None):
if context is None:
context = {}
data = {}
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids, ['pricelist_type', 'hek', 'pek', 'dek'], context=context)[0]

if context.get('xls_export'):
return {'type': 'ir.actions.report.xml',
'report_name': 'product.pricelist.xls',
'datas': data['form']
return self.pool['report'].get_action(cr, uid, [], 'custom_module.report_pricelist', data=data, context=context)

then you just need to create one .py file containing the parser and code to generate the excel report. In my case I want to generate excel report of the products pricelist. I suppose you have the parser and code to generate xls. If you don't have, I can send you the code for reference, by email.

Hope this helps you.

Which reporting engine you are using? It doesn't make any difference you are generating report through for or wizard.

on 10/5/15, 6:58 AM

I thought you want to have a pop-up and print xls, as you might have seen with some financial report module. Am also talking about generating .xls file with xlwt python-package. Anyway if you solved your issue, none of these matters :)

Akhil P Sivan
on 10/5/15, 7:07 AM

You need to create a computed binary field. On the property compute assign the name of the function that calculates the field value of this field. '_compute_field' in this example.

def _compute_field(self):
r = open(filename, 'rb').read().encode('base64')
self.computed_field = r


That would compute each time whenever you open form.

on 10/5/15, 6:59 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 8/27/14, 5:22 PM
Seen: 4412 times
Last updated: 12/29/15, 4:26 AM