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
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!
↧