[FIX] web: saveas_ajax, correct filename when data passed directly

In cases where data is directly given to the saveas_ajax controller,
the filename was not correctly set, as no read method was performed.
(The read call is useless as the data is already avaiable in such a case)
In such cases, the filename must be given in advance

opw-626707
This commit is contained in:
Denis Ledoux 2015-01-29 12:47:29 +01:00
parent a4597fe34f
commit 4c2706d685
2 changed files with 5 additions and 2 deletions

View File

@ -1309,7 +1309,7 @@ class Binary(openerpweb.Controller):
if filename_field:
fields.append(filename_field)
if data:
res = { field: data }
res = {field: data, filename_field: jdata.get('filename', None)}
elif id:
res = Model.read([int(id)], fields, context)[0]
else:

View File

@ -5087,14 +5087,17 @@ instance.web.form.FieldBinary = instance.web.form.AbstractField.extend(instance.
} else {
instance.web.blockUI();
var c = instance.webclient.crashmanager;
var filename_fieldname = this.node.attrs.filename;
var filename_field = this.view.fields && this.view.fields[filename_fieldname];
this.session.get_file({
url: '/web/binary/saveas_ajax',
data: {data: JSON.stringify({
model: this.view.dataset.model,
id: (this.view.datarecord.id || ''),
field: this.name,
filename_field: (this.node.attrs.filename || ''),
filename_field: (filename_fieldname || ''),
data: instance.web.form.is_bin_size(value) ? null : value,
filename: filename_field ? filename_field.get('value') : null,
context: this.view.dataset.get_context()
})},
complete: instance.web.unblockUI,