From 02afc0e0aaea64c534453bcf8cbc3f93c1927113 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Wed, 11 Jul 2018 12:51:10 +0200 Subject: [PATCH] [FIX] web: groupby product on package types triggers a js error On a database where many modules are installed (e.g. runbot all), with the option "manage available packaging options per products", doing a groupby "product" on the "package type" list view triggers a js error. It comes from the fact that the fixed_group variable contains a "length" attribute; the _().each function uses this to determine (erroneously) that the object is an array. It thus uses fixed_group[0] to get an undefined, and then tries to access a method of undefined. We replace the each by a simple js loop. opw 1863576 --- addons/web/static/src/js/framework/data.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/framework/data.js b/addons/web/static/src/js/framework/data.js index c160ebaf539..67085819990 100644 --- a/addons/web/static/src/js/framework/data.js +++ b/addons/web/static/src/js/framework/data.js @@ -261,14 +261,15 @@ var QueryGroup = Class.extend({ var count_key = (grouping_fields[0] && grouping_fields[0].split(':')[0]) + '_count'; var aggregates = {}; - _(fixed_group).each(function (value, key) { - if (key.indexOf('__') === 0 + for (var key in fixed_group) { + if (fixed_group.hasOwnProperty(key)) { + if (!(key.indexOf('__') === 0 || _.contains(grouping_fields, key) - || (key === count_key)) { - return; + || (key === count_key))) { + aggregates[key] = fixed_group[key] || 0; + } } - aggregates[key] = value || 0; - }); + } this.model = new Model( model, fixed_group.__context, fixed_group.__domain);