no filename from saveas_ajax

Bug #1252458 reported by Marcin Kieszek
This bug affects 8 people
Affects Status Importance Assigned to Milestone

Bug Description

when I use binary field in my model and want to download the file I don' get a file name. I have found that function saveas_ajax doesn't send proper file name and it leads to this unexpected behavior.

I also found a solution for that, just put 3 lines code after line 1311 in web/controllers/
to have something like that:

if data:
            res = { field: data }
            if filename_field:
                filename_name =[int(id)], [filename_field], context)
                res[filename_field] = filename_name and filename_name[0] and filename_name[0][filename_field] or ''

It works for me, maybe it may helps others.

Marcin Kieszek

description: updated
Revision history for this message
vmikac (vmikac) wrote :

Based on the suggestion above, I made a patch the can be used to fix the bug.

Revision history for this message
JM ABE (jm-abe) wrote :

This suggestion is working for me too.
Thank you very much

Revision history for this message
Florent THOMAS (mailinglist) wrote :


Personnaly I have this error with your patch :
filename_name =[int(id)], [filename_field], context)
ValueError: invalid literal for int() with base 10: ''

What am I missing?

Revision history for this message
Anton Chepurov (anton-chepurov) wrote :

Florent THOMAS and others,

Binary fields seem to work fine for downloading files only when binary fields appear on already existing records, but not when the record is just being created.

E.g. in Florent's case, the binary's parent record does not yet exist in DB, so it doesn't have an ID, and consequently int(id) produces an error.

Therefore, neither the original version of, nor the fixed one will work with new records (typically Transient records, I guess).

A possible yet ugly solution for this would be to first store the record and then reopen it by its ID.
Consider a working example in
Here, act_getfile() first writes to the 'data' binary field, and then reopens the same object by specifying {'res_id':}.
This approach works fine, but requires an extra button (kinda 'Generate my_file') to simply submit the record to DB and to reopen it.

Still waiting for a better solution.
BTW, have a look here:

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers