This question has been flagged
1 Reply
4900 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!

Avatar
Discard
Author Best Answer

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.

Avatar
Discard