https://github.com/odoo/o-spreadsheet/commit/ab6f47f9 [FIX] InternalViewport: compute the actual visible rect of a zone https://github.com/odoo/o-spreadsheet/commit/966c311e [REF] plugins: unify position getters API https://github.com/odoo/o-spreadsheet/commit/9f1c9695 [IMP] model: ignore type property in command payload https://github.com/odoo/o-spreadsheet/commit/862dacbc [REF] selection: rename getPosition to getActivePosition https://github.com/odoo/o-spreadsheet/commit/0144515a [REF] selection: getPosition return main position https://github.com/odoo/o-spreadsheet/commit/38422f4f [FIX] find and replace: scroll on single match. https://github.com/odoo/o-spreadsheet/commit/9be582c7 [FIX] selection_input: traceback when using unbounded ranges https://github.com/odoo/o-spreadsheet/commit/49285322 [IMP] doc: add tables of contents https://github.com/odoo/o-spreadsheet/commit/2c5d86af [IMP] model: config to provide external dependencies https://github.com/odoo/o-spreadsheet/commit/5b442218 [REF] plugins: use object in constructor https://github.com/odoo/o-spreadsheet/commit/ef98be1b [REM] plugins: remove useless modes https://github.com/odoo/o-spreadsheet/commit/4f20d05f [IMP] data: reorganize data top menu closes odoo/odoo#106583 Related: odoo/enterprise#34412 Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
74 lines
2.5 KiB
JavaScript
74 lines
2.5 KiB
JavaScript
/** @odoo-module */
|
|
|
|
import { ormService } from "@web/core/orm_service";
|
|
import { registry } from "@web/core/registry";
|
|
import { makeTestEnv } from "@web/../tests/helpers/mock_env";
|
|
import { nextTick } from "@web/../tests/helpers/utils";
|
|
|
|
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
|
|
import { DataSources } from "@spreadsheet/data_sources/data_sources";
|
|
import { getBasicServerData } from "./data";
|
|
|
|
const { Model } = spreadsheet;
|
|
|
|
/**
|
|
* @typedef {import("@spreadsheet/../tests/utils/data").ServerData} ServerData
|
|
*/
|
|
|
|
export function setupDataSourceEvaluation(model) {
|
|
model.config.external.dataSources.addEventListener("data-source-updated", () => {
|
|
const sheetId = model.getters.getActiveSheetId();
|
|
model.dispatch("EVALUATE_CELLS", { sheetId });
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Create a spreadsheet model with a mocked server environnement
|
|
*
|
|
* @param {object} params
|
|
* @param {object} [params.spreadsheetData] Spreadsheet data to import
|
|
* @param {ServerData} [params.serverData] Data to be injected in the mock server
|
|
* @param {function} [params.mockRPC] Mock rpc function
|
|
*/
|
|
export async function createModelWithDataSource(params = {}) {
|
|
registry.category("services").add("orm", ormService, { force: true });
|
|
const env = await makeTestEnv({
|
|
serverData: params.serverData || getBasicServerData(),
|
|
mockRPC: params.mockRPC,
|
|
});
|
|
const model = new Model(params.spreadsheetData, {
|
|
external: {
|
|
env,
|
|
dataSources: new DataSources(env.services.orm.silent),
|
|
},
|
|
});
|
|
setupDataSourceEvaluation(model);
|
|
await nextTick(); // initial async formulas loading
|
|
return model;
|
|
}
|
|
|
|
/**
|
|
* @param {Model} model
|
|
*/
|
|
export async function waitForDataSourcesLoaded(model) {
|
|
function readAllCellsValue() {
|
|
for (const sheetId of model.getters.getSheetIds()) {
|
|
const cells = model.getters.getEvaluatedCells(sheetId);
|
|
for (const cellId in cells) {
|
|
cells[cellId].value;
|
|
}
|
|
}
|
|
}
|
|
// Read a first time in order to trigger the RPC
|
|
readAllCellsValue();
|
|
//@ts-ignore
|
|
await model.config.external.dataSources.waitForAllLoaded();
|
|
await nextTick();
|
|
// Read a second time to trigger the compute format (which could trigger a RPC for currency, in list)
|
|
readAllCellsValue();
|
|
await nextTick();
|
|
// Read a third time to trigger the RPC to get the correct currency
|
|
readAllCellsValue();
|
|
await nextTick();
|
|
}
|