From ca2060048ef7d0933b3edfd2d6a15a48bfe6373d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 17 Jan 2018 12:11:39 +0100 Subject: [FIX] web: fix issue with multiple pages and relational fields When fetching x2manys in a x2many, the basic model did not properly sort the internal data structure before fetching the data. This is usually not an issue, except when we have an order which is different from the order of the res_ids. In that case, it can cause crash in some conditions, because the results from the fetchx2manybatched were applied to the wrong datapoint. To reproduce this issue, some specific conditions needs to be met. I think that it is easier to refer to the test, instead of trying to explain that. In this commit, we properly sort the data at the correct place. Note that this probably solves a bunch of other related issues, caused by the fact that the internal structure was corrupted. --- addons/web/static/src/js/views/basic/basic_model.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (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 1c25d029cfd..cf7effb5691 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2374,7 +2374,7 @@ var BasicModel = AbstractModel.extend({ }); record.data[fieldName] = list.id; if (!fieldInfo.__no_fetch) { - var def = self._readUngroupedList(list).then(function (list) { + var def = self._readUngroupedList(list).then(function () { return $.when( self._fetchX2ManysBatched(list), self._fetchReferencesBatched(list) @@ -2403,6 +2403,7 @@ var BasicModel = AbstractModel.extend({ var fields = view ? view.fields : fieldInfo.relatedFields; var viewType = view ? view.type : fieldInfo.viewType; list = this._applyX2ManyOperations(list); + this._sortList(list); var x2mRecords = []; // step 1: collect ids -- cgit v1.2.3