Odoo Help


Odoo8. Send file to browser to download (Save As..)

on 4/6/15, 4:43 AM 2,101 views

Hello. How can I send the file, what I have on the disk, to my browser to download, like "save as? Or how can I do that when I've finished to compose my csv? Thanks.

Do you have the solution, I am looking for it too.

on 12/20/15, 10:44 PM

I used a binary field for that. It's not what I looked for, but I have only this solution. The question is not actual for me now, but I think there is another way.

Отправлено из Mail.Ru для Android

понедельник, 21 декабря 2015г., 09:44 +06:00 от JC jcchua-gmail.com@mail.odoo.com>:

Do you have the solution, I am looking for it too.


on 12/21/15, 3:13 AM

Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

On 11/16/16, 1:23 AM

You can use URL-Action to send your file, but before that, you need to dump the data into IRAttachment, then use this attachment to download the file via Browser(URL)

A sample snippet as follows: (in my case am writing into an Excel File & returning the same as downloaded)

# Attach & Print: Excel File 
out = base64.encodestring(result_ExcelFile)
attachment = self.env['ir.attachment'].create({
'name': <file_name>,
'datas': out,
'datas_fname': <file_name>,
'res_model': self._name,
'res_id': self.id,
'type': 'binary'})
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
return {'type' : 'ir.actions.act_url',
'url': base_url + '/web/content/%s/%s'%(attachment.id, <file_name>),
'target': 'self',


Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--

| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 4/6/15, 6:07 AM


"saveas" or "saveas_ajax" python functions are in module web/controllers/main.py in class Binary (but I think you should create yours using what you need in saveas method, because this function use attachment)

(v8) : def saveas(self, model, field, id=None, filename_field=None, **kw):


Thank you for your answer. I know everything you're speaking about, but maybe you didn't understand what I want to get as result. I have the module, where I make my own .csv file and after making process I need to download it via my browser. How can I do that? How can I send it to browser?

on 4/6/15, 6:18 AM

Sorry, it's not very clear => I have the module, where I make my own .csv file (you edit it in odoo ?), => after making process (what process); you should explain all actions you are doing, where ... bye

Cyril Gaspard (GEM)
on 4/6/15, 7:01 AM

In the module I make new csv file? like this out = csv.writer(open("new_file.csv"), delimiter=','). And then I write to this file everything I want. And as result, I want to download the file, new_file.csv, via my browser.

on 4/6/15, 7:55 AM

answer updated

Cyril Gaspard (GEM)
on 4/6/15, 8:35 AM



| 6 5 7
Tbilisi, Georgia
On 4/6/15, 8:24 AM

you can use binary field I think, add a binary field to your model and when you make new csv file, save this file to the binary field. you'll be able then to download it (normally with binary field you'll have upload too.. but if you try to set this field to readonly, then maybe upload will be disabled(?))

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

1 follower(s)


Asked: 4/6/15, 4:43 AM
Seen: 2101 times
Last updated: 11/16/16, 1:23 AM