From a16013be6636db58a4252fafd67033c6643a1e48 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 23 Feb 2018 13:48:20 +0100 Subject: [FIX] web: multi pages ordered o2m with onchange Let's assume a one2many displayed over several pages with a default order such that a record, say R, that would normally be on page 1 is actually on another page. Moreover, there is an onchange on that one2many which converts all commands 4 (LINK_TO) into commands 1 (UPDATE), which is standard in the ORM. When the first line of the one2many was edited, the record R was fully loaded, whereas it shouldn't have been (as it is not on the current page). So basically, a useless read was performed. Moreover, if there was an x2many field in the one2many list, a crash occurred because relational data of R that shouldn't have been read wasn't postprocessed by the BasicModel. The useless read occurred because the one2many subrecords weren't correctly sorted before checking if some of them/some of their fields should be read. This is not the case anymore. OPW-1816800 --- addons/web/static/src/js/views/basic/basic_model.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index e2cc60f7fc4..18193a5c364 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3804,14 +3804,14 @@ var BasicModel = AbstractModel.extend({ // for multi-pages list datapoints, we might need to read the // order field first to apply the order on all pages - if (list.res_ids.length > list.limit) { - if (!list.orderedResIDs && list.orderedBy.length) { + if (list.res_ids.length > list.limit && list.orderedBy.length) { + if (!list.orderedResIDs) { var fieldNames = _.pluck(list.orderedBy, 'name'); def = this._readMissingFields(list, _.filter(list.res_ids, _.isNumber), fieldNames); - def.then(function () { - self._sortList(list); - }); } + def.then(function () { + self._sortList(list); + }); } return def.then(function () { var resIDs = []; -- cgit v1.2.3