Skip to content

Commit

Permalink
[REF] *: rename unity_web_search_read into web_search_read
Browse files Browse the repository at this point in the history
Part-of: odoo#133617
  • Loading branch information
aab-odoo committed Aug 31, 2023
1 parent 1d71e35 commit 2a121a3
Show file tree
Hide file tree
Showing 32 changed files with 430 additions and 471 deletions.
2 changes: 1 addition & 1 deletion addons/board/static/tests/board_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ QUnit.module("Board", (hooks) => {
views: [[4, "list"]],
};
}
if (route === "/web/dataset/call_kw/partner/unity_web_search_read") {
if (route === "/web/dataset/call_kw/partner/web_search_read") {
assert.deepEqual(
args.kwargs.domain,
[["foo", "!=", "False"]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ QUnit.test("list activity widget with no activity", async (assert) => {
});
await contains(".o-mail-ActivityButton i.text-muted");
await contains(".o-mail-ListActivity-summary:eq(0):contains()");
assert.verifySteps(["/web/dataset/call_kw/res.users/unity_web_search_read"]);
assert.verifySteps(["/web/dataset/call_kw/res.users/web_search_read"]);
});

QUnit.test("list activity widget with activities", async (assert) => {
Expand Down Expand Up @@ -99,7 +99,7 @@ QUnit.test("list activity widget with activities", async (assert) => {
);
await contains(".o_data_row:eq(1) .o-mail-ActivityButton i.text-success.fa-clock-o");
assert.strictEqual($(".o_data_row:eq(1) .o-mail-ListActivity-summary")[0].innerText, "Type 2");
assert.verifySteps(["/web/dataset/call_kw/res.users/unity_web_search_read"]);
assert.verifySteps(["/web/dataset/call_kw/res.users/web_search_read"]);
});

QUnit.test("list activity widget with exception", async (assert) => {
Expand Down Expand Up @@ -142,7 +142,7 @@ QUnit.test("list activity widget with exception", async (assert) => {
});
await contains(".o-mail-ActivityButton i.text-warning.fa-warning");
await contains(".o-mail-ListActivity-summary:eq(0):contains(Warning)");
assert.verifySteps(["/web/dataset/call_kw/res.users/unity_web_search_read"]);
assert.verifySteps(["/web/dataset/call_kw/res.users/web_search_read"]);
});

QUnit.test("list activity widget: open dropdown", async (assert) => {
Expand Down Expand Up @@ -226,7 +226,7 @@ QUnit.test("list activity widget: open dropdown", async (assert) => {
await click(".o-mail-ActivityListPopoverItem-markAsDone:eq(0)"); // mark the first activity as done
await click(".o-mail-ActivityMarkAsDone button[aria-label='Done']"); // confirm
await contains(".o-mail-ListActivity-summary:eq(0):contains(Meet FP)");
assert.verifySteps(["unity_web_search_read", "activity_format", "action_feedback", "web_read"]);
assert.verifySteps(["web_search_read", "activity_format", "action_feedback", "web_read"]);
});

QUnit.test("list activity exception widget with activity", async () => {
Expand Down
2 changes: 1 addition & 1 deletion addons/mail/static/tests/web/debug_menu_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ QUnit.test("Manage Messages", async (assert) => {
if (method === "check_access_rights") {
return true;
}
if (method === "unity_web_search_read" && model === "mail.message") {
if (method === "web_search_read" && model === "mail.message") {
assert.step("message_read");
const { context, domain } = kwargs;
assert.strictEqual(context.default_res_id, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ QUnit.module("spreadsheet > Metadata Repository", { beforeEach }, () => {
assert.verifySteps([]);

await nextTick();
assert.verifySteps(["unity_web_search_read-A-[1,2]", "unity_web_search_read-B-[1]", "labels-fetched"]);
assert.verifySteps(["web_search_read-A-[1,2]", "web_search_read-B-[1]", "labels-fetched"]);

assert.strictEqual(metadataRepository.getRecordDisplayName("A", 1), "1");
assert.strictEqual(metadataRepository.getRecordDisplayName("A", 2), "2");
Expand All @@ -120,11 +120,11 @@ QUnit.module("spreadsheet > Metadata Repository", { beforeEach }, () => {
assert.verifySteps([]);

await nextTick();
assert.verifySteps(["unity_web_search_read-A-[1]"]);
assert.verifySteps(["web_search_read-A-[1]"]);

assert.throws(() => metadataRepository.getRecordDisplayName("A", 2));
await nextTick();
assert.verifySteps(["unity_web_search_read-A-[2]"]);
assert.verifySteps(["web_search_read-A-[2]"]);
});

QUnit.test(
Expand All @@ -147,7 +147,7 @@ QUnit.module("spreadsheet > Metadata Repository", { beforeEach }, () => {
assert.strictEqual(metadataRepository.getRecordDisplayName("A", 1), "test");

await nextTick();
assert.verifySteps(["unity_web_search_read-A-[1]"]);
assert.verifySteps(["web_search_read-A-[1]"]);
assert.strictEqual(metadataRepository.getRecordDisplayName("A", 1), "test");
}
);
Expand Down Expand Up @@ -178,7 +178,7 @@ QUnit.module("spreadsheet > Metadata Repository", { beforeEach }, () => {
assert.verifySteps([]);

await nextTick();
assert.verifySteps(["unity_web_search_read-A-[1]", "unity_web_search_read-B-[1,2]"]);
assert.verifySteps(["web_search_read-A-[1]", "web_search_read-B-[1,2]"]);

assert.strictEqual(metadataRepository.getRecordDisplayName("A", 1), "1");
assert.throws(
Expand Down
4 changes: 2 additions & 2 deletions addons/test_mail/static/tests/activity_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ QUnit.module("test_mail", {}, function () {
const { openView } = await start({
serverData,
mockRPC: function (route, args) {
if (["get_activity_data", "unity_web_search_read"].includes(args.method)) {
if (["get_activity_data", "web_search_read"].includes(args.method)) {
assert.step(JSON.stringify(args.kwargs.domain));
}
},
Expand Down Expand Up @@ -1023,7 +1023,7 @@ QUnit.module("test_mail", {}, function () {
const { target, openView } = await start({
serverData,
mockRPC(route, { method, kwargs }, result) {
if (method === "unity_web_search_read") {
if (method === "web_search_read") {
assert.deepEqual(Object.keys(kwargs.specification), ["write_date", "id"]);
return Promise.resolve({
length: 2,
Expand Down
2 changes: 1 addition & 1 deletion addons/web/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Base(models.AbstractModel):
_inherit = 'base'

@api.model
def unity_web_search_read(self, domain, specification, offset=0, limit=None, order=None, count_limit=None):
def web_search_read(self, domain, specification, offset=0, limit=None, order=None, count_limit=None):
records = self.search_fetch(domain, specification.keys(), offset=offset, limit=limit, order=order)
values_records = records.web_read(specification)
return self._format_web_search_read_results(domain, values_records, offset, limit, count_limit)
Expand Down
2 changes: 1 addition & 1 deletion addons/web/static/src/core/orm_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class ORM {
*/
webSearchRead(model, domain, kwargs = {}) {
validateArray("domain", domain);
return this.call(model, "unity_web_search_read", [], { ...kwargs, domain });
return this.call(model, "web_search_read", [], { ...kwargs, domain });
}

/**
Expand Down
2 changes: 1 addition & 1 deletion addons/web/static/src/model/sample_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class SampleServer {
}
this._populateModels();
switch (params.method || params.route) {
case "unity_web_search_read":
case "web_search_read":
return this._mockWebSearchReadUnity(params);
case "web_read_group":
return this._mockWebReadGroup(params);
Expand Down
2 changes: 1 addition & 1 deletion addons/web/static/src/views/fields/radio/radio_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class RadioField extends Component {
specification: { display_name: 1 },
domain: props.domain,
};
const { records } = await orm.call(relation, "unity_web_search_read", [], kwargs);
const { records } = await orm.call(relation, "web_search_read", [], kwargs);
return records.map((record) => [record.id, record.display_name]);
});
}
Expand Down
10 changes: 5 additions & 5 deletions addons/web/static/tests/core/name_service_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ QUnit.test("single loadDisplayNames following addDisplayNames (2)", async (asser
env.services.name.addDisplayNames("dev", { 1: "JUM" });
const displayNames = await env.services.name.loadDisplayNames("dev", [1, 2]);
assert.deepEqual(displayNames, { 1: "JUM", 2: "Pierre" });
assert.verifySteps(["unity_web_search_read", "id(s): 2"]);
assert.verifySteps(["web_search_read", "id(s): 2"]);
});

QUnit.test("loadDisplayNames in batch", async (assert) => {
Expand All @@ -79,7 +79,7 @@ QUnit.test("loadDisplayNames in batch", async (assert) => {
const [displayNames1, displayNames2] = await Promise.all([prom1, prom2]);
assert.deepEqual(displayNames1, { 1: "Julien" });
assert.deepEqual(displayNames2, { 2: "Pierre" });
assert.verifySteps(["unity_web_search_read", "id(s): 1, 2"]);
assert.verifySteps(["web_search_read", "id(s): 1, 2"]);
});

QUnit.test("loadDisplayNames on different models", async (assert) => {
Expand All @@ -101,7 +101,7 @@ QUnit.test("loadDisplayNames on different models", async (assert) => {
const [displayNames1, displayNames2] = await Promise.all([prom1, prom2]);
assert.deepEqual(displayNames1, { 1: "Julien" });
assert.deepEqual(displayNames2, { 1: "Damien" });
assert.verifySteps(["unity_web_search_read", "dev", "id(s): 1", "unity_web_search_read", "PO", "id(s): 1"]);
assert.verifySteps(["web_search_read", "dev", "id(s): 1", "web_search_read", "PO", "id(s): 1"]);
});

QUnit.test("invalid id", async (assert) => {
Expand All @@ -121,7 +121,7 @@ QUnit.test("inaccessible or missing id", async (assert) => {
const env = await makeTestEnv({ serverData, mockRPC });
const displayNames = await env.services.name.loadDisplayNames("dev", [3]);
assert.deepEqual(displayNames, { 3: ERROR_INACCESSIBLE_OR_MISSING });
assert.verifySteps(["unity_web_search_read"]);
assert.verifySteps(["web_search_read"]);
});

QUnit.test("batch + inaccessible/missing", async (assert) => {
Expand All @@ -138,5 +138,5 @@ QUnit.test("batch + inaccessible/missing", async (assert) => {
const [displayNames1, displayNames2] = await Promise.all([prom1, prom2]);
assert.deepEqual(displayNames1, { 1: "Julien", 3: ERROR_INACCESSIBLE_OR_MISSING });
assert.deepEqual(displayNames2, { 2: "Pierre", 4: ERROR_INACCESSIBLE_OR_MISSING });
assert.verifySteps(["unity_web_search_read", "id(s): 1, 3, 2, 4"]);
assert.verifySteps(["web_search_read", "id(s): 1, 3, 2, 4"]);
});
4 changes: 2 additions & 2 deletions addons/web/static/tests/core/orm_service_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ QUnit.test("webSearchRead method", async (assert) => {
const env = await makeTestEnv();
const specification = { amount_total: {} };
await env.services.orm.webSearchRead("sale.order", [["user_id", "=", 2]], { specification });
assert.strictEqual(query.route, "/web/dataset/call_kw/sale.order/unity_web_search_read");
assert.strictEqual(query.route, "/web/dataset/call_kw/sale.order/web_search_read");
assert.deepEqual(query.params, {
args: [],
kwargs: {
Expand All @@ -383,7 +383,7 @@ QUnit.test("webSearchRead method", async (assert) => {
domain: [["user_id", "=", 2]],
specification: { amount_total: {} },
},
method: "unity_web_search_read",
method: "web_search_read",
model: "sale.order",
});
});
Expand Down
2 changes: 1 addition & 1 deletion addons/web/static/tests/helpers/mock_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ export class MockServer {
return this.mockReadGroup(args.model, args.kwargs);
case "web_read_group":
return this.mockWebReadGroup(args.model, args.kwargs);
case "unity_web_search_read":
case "web_search_read":
return this.mockWebSearchReadUnity(args.model, args.args, args.kwargs);
case "read_progress_bar":
return this.mockReadProgressBar(args.model, args.kwargs);
Expand Down
10 changes: 5 additions & 5 deletions addons/web/static/tests/model/sample_server_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ QUnit.module(
}
const server = new DeterministicSampleServer("res.users", fields["res.users"]);
const { records } = await server.mockRpc({
method: "unity_web_search_read",
method: "web_search_read",
model: "res.users",
specification,
});
Expand Down Expand Up @@ -209,7 +209,7 @@ QUnit.module(

const server = new DeterministicSampleServer("res.country", fields["res.country"]);
const { records } = await server.mockRpc({
method: "unity_web_search_read",
method: "web_search_read",
model: "res.country",
specification: { display_name: {} },
});
Expand All @@ -223,7 +223,7 @@ QUnit.module(
const server = new DeterministicSampleServer("hobbit", fields.hobbit);

const { records } = await server.mockRpc({
method: "unity_web_search_read",
method: "web_search_read",
model: "hobbit",
specification: { display_name: {} },
});
Expand All @@ -239,7 +239,7 @@ QUnit.module(
const server = new DeterministicSampleServer("hobbit", fields.hobbit);

const result = await server.mockRpc({
method: "unity_web_search_read",
method: "web_search_read",
model: "hobbit",
specification: { display_name: {} },
});
Expand All @@ -253,7 +253,7 @@ QUnit.module(
const server = new DeterministicSampleServer("res.users", fields["res.users"]);

const result = await server.mockRpc({
method: "unity_web_search_read",
method: "web_search_read",
model: "res.users",
specification: {
manager_id: {
Expand Down
4 changes: 2 additions & 2 deletions addons/web/static/tests/search/search_bar_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ QUnit.module("Search", (hooks) => {

async function mockRPC(_, { method, model, kwargs }) {
if (
method === "unity_web_search_read" &&
method === "web_search_read" &&
model === "partner" &&
kwargs.specification.display_name &&
kwargs.specification.child_properties
Expand Down Expand Up @@ -1374,7 +1374,7 @@ QUnit.module("Search", (hooks) => {

async function mockRPC(route, { method, model, args, kwargs }) {
if (
method === "unity_web_search_read" &&
method === "web_search_read" &&
model === "partner" &&
kwargs.specification.display_name &&
kwargs.specification.child_properties
Expand Down
4 changes: 2 additions & 2 deletions addons/web/static/tests/search/search_panel_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ QUnit.module("Search", (hooks) => {
const webclient = await createWebClient({
serverData,
async mockRPC(route, { kwargs, method }) {
if (method === "unity_web_search_read") {
if (method === "web_search_read") {
assert.step(JSON.stringify(kwargs.domain));
}
},
Expand Down Expand Up @@ -2113,7 +2113,7 @@ QUnit.module("Search", (hooks) => {
const webclient = await createWebClient({
serverData,
async mockRPC(route, { kwargs, method }) {
if (method === "unity_web_search_read") {
if (method === "web_search_read") {
assert.step(JSON.stringify(kwargs.domain));
}
},
Expand Down
16 changes: 8 additions & 8 deletions addons/web/static/tests/views/fields/many2many_field_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ QUnit.module("Fields", (hooks) => {
"get_views",
"web_read",
"get_views",
"unity_web_search_read",
"web_search_read",
"onchange",
]);
modal = target.querySelector(".modal");
Expand Down Expand Up @@ -724,7 +724,7 @@ QUnit.module("Fields", (hooks) => {
"get_views",
"web_read",
"get_views",
"unity_web_search_read",
"web_search_read",
"onchange",
]);

Expand Down Expand Up @@ -784,7 +784,7 @@ QUnit.module("Fields", (hooks) => {
</field>
</form>`,
mockRPC(route, args) {
if (args.method === "unity_web_search_read") {
if (args.method === "web_search_read") {
// done by the SelectCreateDialog
assert.deepEqual(args.kwargs.context, {
abc: 2,
Expand Down Expand Up @@ -946,7 +946,7 @@ QUnit.module("Fields", (hooks) => {

assert.verifySteps([
"get_views", // list view in dialog
"unity_web_search_read", // list view in dialog
"web_search_read", // list view in dialog
"web_read", // relational field (updated)
"write", // save main record
"web_read", // main record
Expand Down Expand Up @@ -1434,7 +1434,7 @@ QUnit.module("Fields", (hooks) => {
</field>
</form>`,
mockRPC(route, args) {
if (args.method === "unity_web_search_read") {
if (args.method === "web_search_read") {
assert.deepEqual(args.kwargs.domain, [
"&",
["id", "in", [2, 3]],
Expand Down Expand Up @@ -1512,9 +1512,9 @@ QUnit.module("Fields", (hooks) => {

assert.verifySteps([
"web_read on partner",
"unity_web_search_read on partner_type",
"web_search_read on partner_type",
"web_read on partner_type",
"unity_web_search_read on partner_type",
"web_search_read on partner_type",
"web_read on partner_type",
]);
});
Expand Down Expand Up @@ -1635,7 +1635,7 @@ QUnit.module("Fields", (hooks) => {
assert.verifySteps(["get_views", "web_read"]);

await addRow(target);
assert.verifySteps(["get_views", "unity_web_search_read"]);
assert.verifySteps(["get_views", "web_search_read"]);

await click(target, ".o_create_button");
assert.strictEqual(
Expand Down
Loading

0 comments on commit 2a121a3

Please sign in to comment.