[FIX] web: fix property assignment in pivot view

Sales > Reporting > Sales
Select the measure "Customer (count)"

TypeError: Cannot add property group_operator, object is not extensible

As the object is immutable we need to workaround the assignment.
The previous fix 35967fabd54f596fa75fb2db7fbb1cfc5d7c8da9
will be moved in the `documents_spreadsheet` code

opw-2606424

closes odoo/odoo#74328

X-original-commit: 865d0f5c4e9e14cbd5ed494f8c9dc75b6a82a78f
Related: odoo/enterprise#19910
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2021-07-27 15:52:03 +00:00
parent 97521cc0b2
commit 2c19d865f9
@@ -971,14 +971,15 @@ var PivotModel = AbstractModel.extend({
acc.push(measure);
return acc;
}
var field = self.fields[measure];
if (field.type === 'many2one') {
field.group_operator = 'count_distinct';
var type = self.fields[measure].type;
var groupOperator = self.fields[measure].group_operator;
if (type === 'many2one') {
groupOperator = 'count_distinct';
}
if (field.group_operator === undefined) {
if (groupOperator === undefined) {
throw new Error("No aggregate function has been provided for the measure '" + measure + "'");
}
acc.push(measure + ':' + field.group_operator);
acc.push(measure + ':' + groupOperator);
return acc;
},
[]