diff --git a/addons/spreadsheet/static/src/data_sources/data_sources.js b/addons/spreadsheet/static/src/data_sources/data_sources.js index 7c9de63fee3..a7d9ade7e5c 100644 --- a/addons/spreadsheet/static/src/data_sources/data_sources.js +++ b/addons/spreadsheet/static/src/data_sources/data_sources.js @@ -17,7 +17,7 @@ const { EventBus } = owl; export class DataSources extends EventBus { constructor(orm) { super(); - this._orm = orm; + this._orm = orm.silent; this._metadataRepository = new MetadataRepository(orm); this._metadataRepository.addEventListener("labels-fetched", () => this.notify()); /** @type {Object.} */ diff --git a/addons/spreadsheet/static/src/data_sources/metadata_repository.js b/addons/spreadsheet/static/src/data_sources/metadata_repository.js index 150862292a4..d8807a638aa 100644 --- a/addons/spreadsheet/static/src/data_sources/metadata_repository.js +++ b/addons/spreadsheet/static/src/data_sources/metadata_repository.js @@ -39,7 +39,7 @@ const { EventBus } = owl; export class MetadataRepository extends EventBus { constructor(orm) { super(); - this.orm = orm.silent; + this.orm = orm; this.serverData = new ServerData(this.orm, { whenDataIsFetched: () => this.trigger("labels-fetched"), diff --git a/addons/spreadsheet/static/src/list/list_data_source.js b/addons/spreadsheet/static/src/list/list_data_source.js index 5b1c1ef14e2..e41cc567baf 100644 --- a/addons/spreadsheet/static/src/list/list_data_source.js +++ b/addons/spreadsheet/static/src/list/list_data_source.js @@ -36,7 +36,6 @@ export default class ListDataSource extends OdooViewsDataSource { constructor(services, params) { super(services, params); this.limit = params.limit; - this._orm = services.orm; this.data = []; } diff --git a/addons/spreadsheet/static/tests/data_fetching/metadata_repository_test.js b/addons/spreadsheet/static/tests/data_fetching/metadata_repository_test.js index 900ee5963cc..d2c5d4bb522 100644 --- a/addons/spreadsheet/static/tests/data_fetching/metadata_repository_test.js +++ b/addons/spreadsheet/static/tests/data_fetching/metadata_repository_test.js @@ -8,11 +8,9 @@ QUnit.module("spreadsheet > Metadata Repository", {}, () => { assert.expect(6); const orm = { - silent: { - call: async (model, method) => { - assert.step(`${method}-${model}`); - return model; - }, + call: async (model, method) => { + assert.step(`${method}-${model}`); + return model; }, }; @@ -33,14 +31,12 @@ QUnit.module("spreadsheet > Metadata Repository", {}, () => { assert.expect(6); const orm = { - silent: { - call: async (model, method, args) => { - if (method === "display_name_for" && model === "ir.model") { - const [modelName] = args[0]; - assert.step(`${modelName}`); - return [{ display_name: modelName, model: modelName }]; - } - }, + call: async (model, method, args) => { + if (method === "display_name_for" && model === "ir.model") { + const [modelName] = args[0]; + assert.step(`${modelName}`); + return [{ display_name: modelName, model: modelName }]; + } }, }; @@ -60,7 +56,7 @@ QUnit.module("spreadsheet > Metadata Repository", {}, () => { QUnit.test("Register label correctly memorize labels", function (assert) { assert.expect(2); - const metadataRepository = new MetadataRepository({ silent: {} }); + const metadataRepository = new MetadataRepository({}); assert.strictEqual(metadataRepository.getLabel("model", "field", "value"), undefined); const label = "label"; @@ -70,12 +66,10 @@ QUnit.module("spreadsheet > Metadata Repository", {}, () => { QUnit.test("Name_get are collected and executed once by clock", async function (assert) { const orm = { - silent: { - call: async (model, method, args) => { - const ids = args[0]; - assert.step(`${method}-${model}-[${ids.join(",")}]`); - return ids.map((id) => [id, id.toString()]); - }, + call: async (model, method, args) => { + const ids = args[0]; + assert.step(`${method}-${model}-[${ids.join(",")}]`); + return ids.map((id) => [id, id.toString()]); }, }; @@ -105,12 +99,10 @@ QUnit.module("spreadsheet > Metadata Repository", {}, () => { QUnit.test("Name_get to fetch are cleared after being fetched", async function (assert) { const orm = { - silent: { - call: async (model, method, args) => { - const ids = args[0]; - assert.step(`${method}-${model}-[${ids.join(",")}]`); - return ids.map((id) => [id, id.toString()]); - }, + call: async (model, method, args) => { + const ids = args[0]; + assert.step(`${method}-${model}-[${ids.join(",")}]`); + return ids.map((id) => [id, id.toString()]); }, }; @@ -131,12 +123,10 @@ QUnit.module("spreadsheet > Metadata Repository", {}, () => { "Assigning a result after triggering the request should not crash", async function (assert) { const orm = { - silent: { - call: async (model, method, args) => { - const ids = args[0]; - assert.step(`${method}-${model}-[${ids.join(",")}]`); - return ids.map((id) => [id, id.toString()]); - }, + call: async (model, method, args) => { + const ids = args[0]; + assert.step(`${method}-${model}-[${ids.join(",")}]`); + return ids.map((id) => [id, id.toString()]); }, }; @@ -157,15 +147,13 @@ QUnit.module("spreadsheet > Metadata Repository", {}, () => { "Name_get will retry with one id by request in case of failure", async function (assert) { const orm = { - silent: { - call: async (model, method, args) => { - const ids = args[0]; - assert.step(`${method}-${model}-[${ids.join(",")}]`); - if (model === "B" && ids.includes(1)) { - throw new Error("Missing"); - } - return ids.map((id) => [id, id.toString()]); - }, + call: async (model, method, args) => { + const ids = args[0]; + assert.step(`${method}-${model}-[${ids.join(",")}]`); + if (model === "B" && ids.includes(1)) { + throw new Error("Missing"); + } + return ids.map((id) => [id, id.toString()]); }, }; diff --git a/addons/spreadsheet/static/tests/utils/model.js b/addons/spreadsheet/static/tests/utils/model.js index 37e37169ead..dc3df219818 100644 --- a/addons/spreadsheet/static/tests/utils/model.js +++ b/addons/spreadsheet/static/tests/utils/model.js @@ -40,7 +40,7 @@ export async function createModelWithDataSource(params = {}) { const model = new Model(params.spreadsheetData, { custom: { env, - dataSources: new DataSources(env.services.orm.silent), + dataSources: new DataSources(env.services.orm), }, }); setupDataSourceEvaluation(model);