[IMP] web: add searchCount implementation in ORM service

Part-of: odoo/odoo#92475
This commit is contained in:
Xavier BOL (xbo)
2022-06-30 09:29:41 +02:00
committed by Aaron Bohy
parent 178aa2360b
commit 5501744a83
2 changed files with 28 additions and 0 deletions
@@ -177,6 +177,14 @@ export class ORM {
return this.call(model, "search_read", [], kwargs);
}
searchCount(model, domain, ctx = {}) {
validateArray('domain', domain);
const kwargs = {
context: ctx,
};
return this.call(model, 'search_count', [domain], kwargs);
}
unlink(model, ids, ctx) {
validatePrimitiveList("ids", "number", ids);
if (!ids.length) {
@@ -257,6 +257,26 @@ QUnit.test("searchRead method", async (assert) => {
});
});
QUnit.test("searchCount method", async (assert) => {
const [query, rpc] = makeFakeRPC();
serviceRegistry.add("rpc", rpc);
const env = await makeTestEnv();
await env.services.orm.searchCount("sale.order", [["user_id", "=", 2]]);
assert.strictEqual(query.route, "/web/dataset/call_kw/sale.order/search_count");
assert.deepEqual(query.params, {
args: [[["user_id", "=", 2]]],
kwargs: {
context: {
lang: "en",
tz: "taht",
uid: 7,
},
},
method: "search_count",
model: "sale.order",
});
});
QUnit.test("webSearchRead method", async (assert) => {
const [query, rpc] = makeFakeRPC();
serviceRegistry.add("rpc", rpc);