[IMP] web: add searchCount implementation in ORM service
Part-of: odoo/odoo#92475
This commit is contained in:
committed by
Aaron Bohy
parent
178aa2360b
commit
5501744a83
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user