From 4d760b9e8c47d064e7d0dc382b06c3d8989f6dc7 Mon Sep 17 00:00:00 2001 From: "Laurent Stukkens (LTU)" Date: Tue, 13 Dec 2022 16:55:28 +0000 Subject: [PATCH] [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 --- addons/web/static/src/views/sample_server.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/sample_server.js b/addons/web/static/src/views/sample_server.js index dc98d30501b..2b7dabdaf36 100644 --- a/addons/web/static/src/views/sample_server.js +++ b/addons/web/static/src/views/sample_server.js @@ -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 }