From a4fa2a33f985b00914b40fca5781472319962c87 Mon Sep 17 00:00:00 2001 From: XavierDo Date: Tue, 25 Sep 2018 16:36:13 +0200 Subject: [FIX] web: order read_group by aggregable fields only in list view The read_group method will ignore and display a warning when giving an order on a non-aggregable field. Therefore, when accessing a list of record from a list view group by some field and ordered on another one, a warning will appear in logs (making the nightly clikall test yellow) The solution here is to only order by current group by field and on aggregable fields. We want to keep the user order to know the ASC/DESC information. --- addons/web/static/src/js/views/basic/basic_model.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic') 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 695e8147c7f..94d0ea78c0e 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -4006,6 +4006,9 @@ var BasicModel = AbstractModel.extend({ var groupByField = list.groupedBy[0]; var rawGroupBy = groupByField.split(':')[0]; var fields = _.uniq(list.getFieldNames().concat(rawGroupBy)); + var orderedBy = _.filter(list.orderedBy, function(order){ + return order.name === rawGroupBy || list.fields[order.name].group_operator !== undefined; + }); return this._rpc({ model: list.model, method: 'read_group', @@ -4013,7 +4016,7 @@ var BasicModel = AbstractModel.extend({ domain: list.domain, context: list.context, groupBy: list.groupedBy, - orderBy: list.orderedBy, + orderBy: orderedBy, lazy: true, }) .then(function (groups) { -- cgit v1.2.3