[IMP] web: improve sample server

Before this commit, the aggregate function must be defined to be able
to correctly aggregate the sample data.

This commit searches the aggregate function in the fields definition
when no aggregate function is defined to a field in `fields` parameter
of the `read_group` method.

task-2702636

Part-of: odoo/odoo#108605
This commit is contained in:
Laurent Stukkens (LTU)
2023-03-09 20:52:51 +01:00
committed by Xavier Bol (xbo)
parent 16cf4f4106
commit 4d760b9e8c
+5 -1
View File
@@ -467,7 +467,11 @@ export class SampleServer {
const measures = [];
for (const measureSpec of params.fields || Object.keys(fields)) {
const matches = measureSpec.match(MEASURE_SPEC_REGEX);
const { fieldName, aggregateFunction, measure } = (matches && matches.groups) || {};
let { fieldName, aggregateFunction, measure } = (matches && matches.groups) || {};
if (!aggregateFunction && fieldName in fields && fields[fieldName].group_operator) {
aggregateFunction = fields[fieldName].group_operator;
measure = fieldName;
}
if (!fieldName && !measure) {
continue; // this is for _count measure
}