Odoo Help


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.


How to Download xls file stored in Ir_attachment or open an xls file saved in local?

Mihai Marius
on 10/5/15, 7:44 AM 464 views


I use odoo8 with old api for the moment.

I have created an xls file and stored it in ir_attachment.

Now i need to download it so the client user can choose to download it in a selected local location or ope the xls file using microsoft excel or any app which can open xls file.

I can see Odoo is using saveas and saveas_ajax, but i'm not able to make that work (not much details on passing data to those methods).

So the question is:

  • how to download the xls file in a location that needs to be chosen by the web user?

  • or how to write the xls file locally to client side in a location that is chosen by the client user?

Many thanks in advance!

Mihai Marius
On 10/8/15, 5:11 AM


Answer found.

After creating the record in ir.attachment you can return:

new_attach = attachment_obj.create(cr, uid, attachment_data)

return {

'type' : 'ir.actions.act_url',

'url': '/web/binary/saveas?model=ir.attachment&field=datas&filename_field=name&id=%s' % ( new_attach, ),

'target': 'self',


Where new_attach is the id of the new created record in ir.attachment.

The result is the open/save file windows dialog.

Many thanks!

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

1 follower(s)


Asked: 10/5/15, 7:44 AM
Seen: 464 times
Last updated: 10/8/15, 6:43 AM