jdata = simplejson.loads(data)
model = jdata['model']
field = jdata['field']
+ data = jdata['data']
id = jdata.get('id', None)
filename_field = jdata.get('filename_field', None)
context = jdata.get('context', {})
fields = [field]
if filename_field:
fields.append(filename_field)
- if id:
+ if data:
+ res = { field: data }
+ elif id:
res = Model.read([int(id)], fields, context)[0]
else:
res = Model.default_get(fields, context)
return _.all(stack, _.identity);
};
+instance.web.form.is_bin_size = function(v) {
+ return /^\d+(\.\d*)? \w+$/.test(v);
+};
+
/**
* Must be applied over an class already possessing the PropertiesMixin.
*
if (!value) {
this.do_warn(_t("Save As..."), _t("The field is empty, there's nothing to save !"));
ev.stopPropagation();
- } else if (this._dirty_flag) {
- var link = this.$('.oe_form_binary_file_save_data')[0];
- link.download = this.filename || "download.bin"; // Works on only on Google Chrome
- //link.target = '_blank';
- link.href = "data:application/octet-stream;base64," + value;
} else {
instance.web.blockUI();
var c = instance.webclient.crashmanager;
id: (this.view.datarecord.id || ''),
field: this.name,
filename_field: (this.node.attrs.filename || ''),
+ data: instance.web.form.is_bin_size(value) ? null : value,
context: this.view.dataset.get_context()
})},
complete: instance.web.unblockUI,
render_value: function() {
var self = this;
var url;
- if (this.get('value') && ! /^\d+(\.\d*)? \w+$/.test(this.get('value'))) {
+ if (this.get('value') && !instance.web.form.is_bin_size(this.get('value'))) {
url = 'data:image/png;base64,' + this.get('value');
} else if (this.get('value')) {
var id = JSON.stringify(this.view.datarecord.id || null);
kanban_image: function(model, field, id, cache, options) {
options = options || {};
var url;
- if (this.record[field] && this.record[field].value && ! /^\d+(\.\d*)? \w+$/.test(this.record[field].value)) {
+ if (this.record[field] && this.record[field].value && !instance.web.form.is_bin_size(this.record[field].value)) {
url = 'data:image/png;base64,' + this.record[field].value;
} else if (this.record[field] && ! this.record[field].value) {
url = "/web/static/src/img/placeholder.png";