From f94f50c7e86a444508b096c8e9693c8d22a7abb4 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Mon, 24 Feb 2014 12:05:54 +0100 Subject: [FIX] fixes a crash caused by incorrect use of date/datetime fields of the form 'date:interval': the list view in some case tried to format the strings as a date, and it could not parse it. lp bug: https://launchpad.net/bugs/1279382 fixed bzr revid: ged@openerp.com-20140224110554-y007810prx7qg5yi --- addons/web/static/src/js/data.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/data.js') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index cc595c30688..24a4dc3dd2a 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -221,11 +221,12 @@ instance.web.QueryGroup = instance.web.Class.extend({ {__context: {group_by: []}, __domain: []}, read_group_group); + var raw_field = grouping_field && grouping_field.split(':')[0]; var aggregates = {}; _(fixed_group).each(function (value, key) { if (key.indexOf('__') === 0 - || key === grouping_field - || key === grouping_field + '_count') { + || key === raw_field + || key === raw_field + '_count') { return; } aggregates[key] = value || 0; @@ -234,7 +235,6 @@ instance.web.QueryGroup = instance.web.Class.extend({ this.model = new instance.web.Model( model, fixed_group.__context, fixed_group.__domain); - var raw_field = grouping_field && grouping_field.split(':')[0]; var group_size = fixed_group[raw_field + '_count'] || fixed_group.__count || 0; var leaf_group = fixed_group.__context.group_by.length === 0; -- cgit v1.2.3 From cdc83a0763700df74e1b959427080c89c87c1c50 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 25 Feb 2014 17:28:13 +0100 Subject: [FIX] dataset.read_ids should always return records in the order of the parameter ids BufferedDataSet.read_ids assumes the input and output orders are the same, and returns wonky results when not the case, which in turns fucks up its cache as it associates ids and records incorrectly. bzr revid: xmo@openerp.com-20140225162813-8ofxpiy1012eehgk --- addons/web/static/src/js/data.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/data.js') diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 24a4dc3dd2a..c24d37ba0c1 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -448,7 +448,8 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin, * Read records. * * @param {Array} ids identifiers of the records to read - * @param {Array} fields fields to read and return, by default all fields are returned + * @param {Array} [fields] fields to read and return, by default all fields are returned + * @param {Object} [options] * @returns {$.Deferred} */ read_ids: function (ids, fields, options) { @@ -456,10 +457,20 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin, return $.Deferred().resolve([]); options = options || {}; - // TODO: reorder results to match ids list return this._model.call('read', - [ids, fields || false], - {context: this.get_context(options.context)}); + [ids, fields || false], + {context: this.get_context(options.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 -- cgit v1.2.3