Odoo Help

Welcome!

This community 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.

0

How to download .xls file in a single click?

By
Yogesh
on 8/27/14, 5:22 PM 2,735 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.

Yogesh
on 10/5/15, 7:00 AM
0

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 12/29/15, 4:26 AM

Hello,

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.

Thanks.

0
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.

0

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

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:

    @api.v7
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']
}
else:
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.

Yogesh
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
0

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.


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

 

That would compute each time whenever you open form.

Yogesh
on 10/5/15, 6:59 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

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