[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
This commit is contained in:
len-odoo
2018-07-16 08:47:06 +02:00
committed by len-odoo
parent 7e44d8f6fc
commit 02afc0e0aa
+7 -6
View File
@@ -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);