diff --git a/addons/web/static/src/core/orm_service.js b/addons/web/static/src/core/orm_service.js index f0703180f1f..c5f43cd1fe9 100644 --- a/addons/web/static/src/core/orm_service.js +++ b/addons/web/static/src/core/orm_service.js @@ -189,6 +189,7 @@ export class ORM { validateArray("domain", domain); validatePrimitiveList("fields", "string", fields); validatePrimitiveList("groupby", "string", groupby); + groupby = [...new Set(groupby)]; return this.call(model, "read_group", [], { ...kwargs, domain, fields, groupby }); } diff --git a/addons/web/static/tests/core/orm_service_tests.js b/addons/web/static/tests/core/orm_service_tests.js index c6ba0299bd6..2e2fc0f3b2e 100644 --- a/addons/web/static/tests/core/orm_service_tests.js +++ b/addons/web/static/tests/core/orm_service_tests.js @@ -297,6 +297,23 @@ QUnit.test("readGroup method", async (assert) => { }); }); +QUnit.test("test readGroup method removes duplicate values from groupby", async (assert) => { + const [query, rpc] = makeFakeRPC(); + serviceRegistry.add("rpc", rpc); + const env = await makeTestEnv(); + await env.services.orm.readGroup( + "sale.order", + [["user_id", "=", 2]], + ["amount_total:sum"], + ["date_order:month", "date_order:month"], + { offset: 1 } + ); + assert.strictEqual(query.route, "/web/dataset/call_kw/sale.order/read_group"); + assert.deepEqual(query.params.kwargs.groupby, ["date_order:month"], + "Duplicate values should be removed from groupby" + ); +}); + QUnit.test("searchRead method", async (assert) => { const [query, rpc] = makeFakeRPC(); serviceRegistry.add("rpc", rpc);