Odoo Help


Change filename of binary field (client side)

Vedran Mikac
on 12/10/13, 4:29 PM 2,190 views

XLS file is generated in onChange event. Binary data gets saved in the field, and can be downloaded and opened without a problem. Only problem is that filename offered by the browser's save dialog is modelName_modelID (until model gets saved).

Snippet from _view.xml

 <field name="node_candidates_fn" invisible="1"/>
 <field name="node_candidates" filename="node_candidates_fn" readonly="True" nolabel="0"/>

node_candidates_fn is set in _defaults using:

'node_candidates_fn': 'NodeCandidatesFromDefault.xls',

And when writing a binary file using:

to_save = {'node_candidates': base64_data,  
           'node_candidates_fn': "NodeCandidatesFromSaveToBinary.xls"}
self.write(cr, uid, ids[0], to_save)

To be on the safe side, result from the onChange event (after saving to binary field) is:

 return {'value': {'node_candidates': base64_data,
                   'node_candidates_fn': 'NodeCandidatesFromOnChangeRetVal.xls'}}

When XLS file gets generated, the download widget shows: "Download NodeCandidatesFromSaveToBinary.xls", but when I click on the link, the filename that is offered by the browser's save dialog is modelName_modelId.

Note: If I save the model, filename offered by the browser's save dialog is NodeCandidatesFromSaveToBinary.xls. Saving model is not preferred!

Vedran Mikac
On 12/11/13, 2:55 PM

Solution to the problem can be found on Launchpad under OpenERP Web bug with title: "no filename from saveas_ajax"

Apply the patch, and things should work as expected.

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

0 follower(s)


Asked: 12/10/13, 4:29 PM
Seen: 2190 times
Last updated: 3/16/15, 8:10 AM