From 8a52f10ceb9e3a70cf729e511a6962bbed952333 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 3 Mar 2020 12:00:43 +0000 Subject: [FIX] web: BasicModel: always set a valid limit When x2many fields are displayed with widgets like many2many_tags, there is no limit on the number of related records to fetch and display. In this case, the 'limit' attribute on the datapoints is undefined. This could lead to weird issues when the limit is used in computation, e.g. var index = list.offset + list.limit; // = NaN There are several occurrences of the above examples in the code, which can be observed in specific scenarios, e.g. the one encoded in the test. In this scenario, when the bug occurs, new records added to editable list views are inserted on top (even if the list is editable="bottom"), but the edited row is the last one. Issue reported on task 2189529 --- addons/web/static/src/js/views/basic/basic_model.js | 2 +- 1 file changed, 1 insertion(+), 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 033d0f670ae..00ff4464eff 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3951,7 +3951,7 @@ var BasicModel = AbstractModel.extend({ groupsOffset: 0, id: _.uniqueId(params.modelName + '_'), isOpen: params.isOpen, - limit: type === 'record' ? 1 : params.limit, + limit: type === 'record' ? 1 : (params.limit || Number.MAX_SAFE_INTEGER), loadMoreOffset: 0, model: params.modelName, offset: params.offset || (type === 'record' ? _.indexOf(res_ids, res_id) : 0), -- cgit v1.2.3