[FIX] web: correct rev 680f955
Missing backport of commit f652402
for buffered dataset
Again, should not be forwardported
This commit is contained in:
parent
9a20018166
commit
f9d43e83c6
|
@ -430,12 +430,30 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin,
|
||||||
read_ids: function (ids, fields, options) {
|
read_ids: function (ids, fields, options) {
|
||||||
if (_.isEmpty(ids))
|
if (_.isEmpty(ids))
|
||||||
return $.Deferred().resolve([]);
|
return $.Deferred().resolve([]);
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
// TODO: reorder results to match ids list
|
var method = 'read';
|
||||||
return this._model.call('read',
|
var ids_arg = ids;
|
||||||
[ids, fields || false],
|
var context = this.get_context(options.context);
|
||||||
{context: this.get_context(options.context)});
|
if (options.check_access_rule === true){
|
||||||
|
method = 'search_read';
|
||||||
|
ids_arg = [['id', 'in', ids]];
|
||||||
|
context = new instance.web.CompoundContext(context, {active_test: false});
|
||||||
|
}
|
||||||
|
return this._model.call(method,
|
||||||
|
[ids_arg, fields || false],
|
||||||
|
{context: context})
|
||||||
|
.then(function (records) {
|
||||||
|
if (records.length <= 1) { return records; }
|
||||||
|
var indexes = {};
|
||||||
|
for (var i = 0; i < ids.length; i++) {
|
||||||
|
indexes[ids[i]] = i;
|
||||||
|
}
|
||||||
|
records.sort(function (a, b) {
|
||||||
|
return indexes[a.id] - indexes[b.id];
|
||||||
|
});
|
||||||
|
return records;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Read a slice of the records represented by this DataSet, based on its
|
* Read a slice of the records represented by this DataSet, based on its
|
||||||
|
|
|
@ -957,20 +957,17 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
} else {
|
} else {
|
||||||
var fields = _.keys(self.fields_view.fields);
|
var fields = _.keys(self.fields_view.fields);
|
||||||
fields.push('display_name');
|
fields.push('display_name');
|
||||||
// Use of search_read instead of read to check if we can still read the record (security rules)
|
return self.dataset.read_index(fields,
|
||||||
return self.dataset.call('search_read', [[['id', '=', self.dataset.ids[self.dataset.index]]], fields],
|
|
||||||
{
|
{
|
||||||
context: {
|
context: {
|
||||||
'bin_size': true,
|
'bin_size': true,
|
||||||
'future_display_name': true
|
'future_display_name': true
|
||||||
}
|
},
|
||||||
|
check_access_rule: true
|
||||||
}).then(function(r) {
|
}).then(function(r) {
|
||||||
if (_.isEmpty(r)){
|
self.trigger('load_record', r);
|
||||||
self.do_action('history_back');
|
}).fail(function (){
|
||||||
}
|
self.do_action('history_back');
|
||||||
else{
|
|
||||||
self.trigger('load_record', r[0]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -529,13 +529,14 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
reload_record: function (record) {
|
reload_record: function (record) {
|
||||||
var self = this;
|
var self = this;
|
||||||
// Use of search_read instead of read to check if we can still read the record (security rules)
|
// Use of search_read instead of read to check if we can still read the record (security rules)
|
||||||
return this.dataset.call('search_read', [
|
return this.dataset.read_ids(
|
||||||
[['id', '=', record.get('id')]],
|
[record.get('id')],
|
||||||
_.pluck(_(this.columns).filter(function (r) {
|
_.pluck(_(this.columns).filter(function (r) {
|
||||||
return r.tag === 'field';
|
return r.tag === 'field';
|
||||||
}), 'name')]
|
}), 'name'),
|
||||||
|
{check_access_rule: true}
|
||||||
).done(function (records) {
|
).done(function (records) {
|
||||||
var values = _.isEmpty(records) ? undefined : records[0];
|
var values = records[0];
|
||||||
if (!values) {
|
if (!values) {
|
||||||
self.records.remove(record);
|
self.records.remove(record);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue