Lucas Lefèvre
2022-09-10 02:54:52 +02:00
parent f78691a6b8
commit 2c06b1dd68
15 changed files with 755 additions and 794 deletions
@@ -32,7 +32,7 @@ async function downloadSpreadsheet(env, action) {
* @returns {Promise}
*/
async function waitForDataLoaded(model) {
model.dispatch("EVALUATE_ALL_SHEETS");
model.dispatch("EVALUATE_CELLS");
return new Promise((resolve, reject) => {
let interval = undefined;
interval = browser.setInterval(() => {
File diff suppressed because it is too large Load Diff
@@ -2948,4 +2948,4 @@
</div>
</div>
</t>
</odoo>
</odoo>
@@ -2,8 +2,7 @@
import { setCellContent } from "@spreadsheet/../tests/utils/commands";
import { getCell, getCellValue } from "@spreadsheet/../tests/utils/getters";
import { nextTick } from "@web/../tests/helpers/utils";
import { createModelWithDataSource } from "@spreadsheet/../tests/utils/model";
import { createModelWithDataSource, waitForDataSourcesLoaded } from "@spreadsheet/../tests/utils/model";
QUnit.module("spreadsheet > Currency");
@@ -18,7 +17,7 @@ QUnit.test("Basic exchange formula", async (assert) => {
});
setCellContent(model, "A1", `=ODOO.CURRENCY.RATE("EUR","USD")`);
assert.strictEqual(getCellValue(model, "A1"), "Loading...");
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "A1"), 0.9);
});
@@ -32,7 +31,7 @@ QUnit.test("Currency rate throw with unknown currency", async (assert) => {
},
});
setCellContent(model, "A1", `=ODOO.CURRENCY.RATE("INVALID","USD")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCell(model, "A1").evaluated.error.message, "Currency rate unavailable.");
});
@@ -47,10 +46,10 @@ QUnit.test("Currency rates are only loaded once", async (assert) => {
},
});
setCellContent(model, "A1", `=ODOO.CURRENCY.RATE("EUR","USD")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.verifySteps(["FETCH"]);
setCellContent(model, "A2", `=ODOO.CURRENCY.RATE("EUR","USD")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.verifySteps([]);
});
@@ -70,6 +69,6 @@ QUnit.test("Currency rates are loaded once by clock", async (assert) => {
});
setCellContent(model, "A1", `=ODOO.CURRENCY.RATE("EUR","USD")`);
setCellContent(model, "A2", `=ODOO.CURRENCY.RATE("EUR","SEK")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.verifySteps(["FETCH:2"]);
});
@@ -6,6 +6,7 @@ import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
import {
createModelWithDataSource,
setupDataSourceEvaluation,
waitForDataSourcesLoaded,
} from "@spreadsheet/../tests/utils/model";
import { createSpreadsheetWithPivotAndList } from "@spreadsheet/../tests/utils/pivot_list";
@@ -891,6 +892,7 @@ QUnit.module("spreadsheet > Global filters model", {}, () => {
}
},
});
await waitForDataSourcesLoaded(model);
assert.verifySteps([
"partner/read_group",
"partner/read_group",
@@ -949,6 +951,7 @@ QUnit.module("spreadsheet > Global filters model", {}, () => {
}
},
});
await waitForDataSourcesLoaded(model);
assert.verifySteps(["partner/read_group"]);
assert.equal(getCellValue(model, "A1"), "");
}
@@ -984,12 +987,14 @@ QUnit.module("spreadsheet > Global filters model", {}, () => {
}
},
});
await waitForDataSourcesLoaded(model);
assert.verifySteps([
"partner/read_group",
"partner/read_group",
"partner/read_group",
"partner/read_group",
]);
assert.strictEqual(getCellValue(model, "A1"), 131);
model.dispatch("ADD_GLOBAL_FILTER", {
filter: {
id: "42",
@@ -1002,6 +1007,7 @@ QUnit.module("spreadsheet > Global filters model", {}, () => {
defaultValue: {}, // no default value!
},
});
assert.strictEqual(getCellValue(model, "A1"), 131);
assert.verifySteps([]);
});
@@ -1165,7 +1171,9 @@ QUnit.module("spreadsheet > Global filters model", {}, () => {
const { model } = await createSpreadsheetWithPivotAndList();
await addGlobalFilter(model, THIS_YEAR_FILTER);
const [filter] = model.getters.getGlobalFilters();
const filterPlugin = model["handlers"].find((handler) => handler instanceof FiltersEvaluationPlugin);
const filterPlugin = model["handlers"].find(
(handler) => handler instanceof FiltersEvaluationPlugin
);
const exportData = { styles: [], sheets: [] };
filterPlugin.exportForExcel(exportData);
const filterSheet = exportData.sheets[0];
@@ -51,7 +51,7 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
const { model } = await createSpreadsheetWithList();
setCellContent(model, "A1", `=ODOO.LIST(1,1,"active")`);
assert.strictEqual(getCellValue(model, "A1"), "Loading...");
await nextTick(); // Await for batching collection of missing fields
await waitForDataSourcesLoaded(model); // Await for batching collection of missing fields
assert.strictEqual(getCellValue(model, "A1"), true);
});
@@ -291,7 +291,7 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
uid: 4,
};
patchWithCleanup(session, testSession);
await createModelWithDataSource({
const model = await createModelWithDataSource({
spreadsheetData,
mockRPC: function (route, { model, method, kwargs }) {
if (model !== "partner") {
@@ -309,6 +309,7 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
}
},
});
await waitForDataSourcesLoaded(model);
assert.verifySteps(["search_read"]);
});
@@ -377,16 +378,16 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
domain: [["foo", "in", [55]]],
});
assert.deepEqual(model.getters.getListDefinition(listId).domain, [["foo", "in", [55]]]);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "B2"), "");
model.dispatch("REQUEST_UNDO");
await nextTick();
await waitForDataSourcesLoaded(model);
assert.deepEqual(model.getters.getListDefinition(listId).domain, []);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "B2"), "TRUE");
model.dispatch("REQUEST_REDO");
assert.deepEqual(model.getters.getListDefinition(listId).domain, [["foo", "in", [55]]]);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "B2"), "");
});
@@ -9,7 +9,10 @@ import {
import { createSpreadsheetWithPivot } from "@spreadsheet/../tests/utils/pivot";
import CommandResult from "@spreadsheet/o_spreadsheet/cancelled_reason";
import { setCellContent } from "@spreadsheet/../tests/utils/commands";
import { createModelWithDataSource } from "@spreadsheet/../tests/utils/model";
import {
createModelWithDataSource,
waitForDataSourcesLoaded,
} from "@spreadsheet/../tests/utils/model";
import { makeDeferred, nextTick, patchWithCleanup } from "@web/../tests/helpers/utils";
import { session } from "@web/session";
@@ -279,7 +282,7 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
uid: 4,
};
patchWithCleanup(session, testSession);
await createModelWithDataSource({
const model = await createModelWithDataSource({
spreadsheetData,
mockRPC: function (route, { model, method, kwargs }) {
if (model !== "partner") {
@@ -293,6 +296,7 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
}
},
});
await waitForDataSourcesLoaded(model);
assert.verifySteps(["read_group", "read_group", "read_group", "read_group"]);
}
);
@@ -329,7 +333,7 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
},
},
};
await createModelWithDataSource({
const model = await createModelWithDataSource({
spreadsheetData,
mockRPC: function (route, { model, method, kwargs }) {
if (model === "partner" && method === "fields_get") {
@@ -339,6 +343,7 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
}
},
});
await waitForDataSourcesLoaded(model);
assert.verifySteps(["partner/fields_get"]);
});
@@ -481,7 +486,7 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
content: `=ODOO.PIVOT.HEADER("1", "product_id", "1111111")`,
sheetId,
});
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(
getCell(model, "E10").evaluated.error.message,
"Unable to fetch the label of 1111111 of model product"
@@ -501,7 +506,7 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
});
setCellContent(model, "F10", `=ODOO.PIVOT.HEADER("1", "product_id", A25)`);
assert.equal(getCell(model, "A25"), null, "the cell should be empty");
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(getCellValue(model, "F10"), "None");
});
@@ -650,16 +655,16 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
domain: [["foo", "in", [55]]],
});
assert.deepEqual(model.getters.getPivotDefinition(pivotId).domain, [["foo", "in", [55]]]);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "B4"), "");
model.dispatch("REQUEST_UNDO");
await nextTick();
await waitForDataSourcesLoaded(model);
assert.deepEqual(model.getters.getPivotDefinition(pivotId).domain, []);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "B4"), 11);
model.dispatch("REQUEST_REDO");
assert.deepEqual(model.getters.getPivotDefinition(pivotId).domain, [["foo", "in", [55]]]);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "B4"), "");
});
@@ -1,10 +1,12 @@
/** @odoo-module */
import { nextTick } from "@web/../tests/helpers/utils";
import { setCellContent } from "@spreadsheet/../tests/utils/commands";
import { getCell, getCellValue } from "@spreadsheet/../tests/utils/getters";
import { createSpreadsheetWithPivot } from "@spreadsheet/../tests/utils/pivot";
import { createModelWithDataSource } from "@spreadsheet/../tests/utils/model";
import {
createModelWithDataSource,
waitForDataSourcesLoaded,
} from "@spreadsheet/../tests/utils/model";
QUnit.module("spreadsheet > positional pivot formula", {}, () => {
QUnit.test("Can have positional args in pivot formula", async function (assert) {
@@ -132,7 +134,7 @@ QUnit.module("spreadsheet > positional pivot formula", {}, () => {
setCellContent(model, "C2", `=ODOO.PIVOT(1,"probability","#bar",2,"#foo",2)`);
setCellContent(model, "D1", `=ODOO.PIVOT(1,"probability","#bar",1)`);
setCellContent(model, "D2", `=ODOO.PIVOT(1,"probability","#bar",2)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "A1"), "No");
assert.strictEqual(getCellValue(model, "A2"), "Yes");
assert.strictEqual(getCellValue(model, "B1"), "");
@@ -170,7 +172,7 @@ QUnit.module("spreadsheet > positional pivot formula", {}, () => {
setCellContent(model, "C2", `=ODOO.PIVOT(1,"probability","#bar",2,"#foo",2)`);
setCellContent(model, "D1", `=ODOO.PIVOT(1,"probability","#bar",1)`);
setCellContent(model, "D2", `=ODOO.PIVOT(1,"probability","#bar",2)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "A1"), "Yes");
assert.strictEqual(getCellValue(model, "A2"), "No");
assert.strictEqual(getCellValue(model, "B1"), 11);
@@ -209,7 +211,7 @@ QUnit.module("spreadsheet > positional pivot formula", {}, () => {
setCellContent(model, "C2", `=ODOO.PIVOT(1,"probability","#bar",2,"#foo",2)`);
setCellContent(model, "D1", `=ODOO.PIVOT(1,"probability","#bar",1)`);
setCellContent(model, "D2", `=ODOO.PIVOT(1,"probability","#bar",2)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "A1"), "Yes");
assert.strictEqual(getCellValue(model, "A2"), "No");
assert.strictEqual(getCellValue(model, "B1"), 11);
@@ -248,7 +250,7 @@ QUnit.module("spreadsheet > positional pivot formula", {}, () => {
setCellContent(model, "C2", `=ODOO.PIVOT(1,"probability","#bar",2,"#foo",2)`);
setCellContent(model, "D1", `=ODOO.PIVOT(1,"probability","#bar",1)`);
setCellContent(model, "D2", `=ODOO.PIVOT(1,"probability","#bar",2)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "A1"), "No");
assert.strictEqual(getCellValue(model, "A2"), "Yes");
assert.strictEqual(getCellValue(model, "B1"), "");
@@ -284,7 +286,7 @@ QUnit.module("spreadsheet > positional pivot formula", {}, () => {
setCellContent(model, "B11", `=ODOO.PIVOT(1,"probability","#product_id",2)`);
setCellContent(model, "C10", `=ODOO.PIVOT(1,"foo","#product_id",1)`);
setCellContent(model, "C11", `=ODOO.PIVOT(1,"foo","#product_id",2)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "A10"), "xphone");
assert.strictEqual(getCellValue(model, "A11"), "xpad");
assert.strictEqual(getCellValue(model, "B10"), 10);
@@ -318,7 +320,7 @@ QUnit.module("spreadsheet > positional pivot formula", {}, () => {
setCellContent(model, "B11", `=ODOO.PIVOT(1,"probability","#product_id",2)`);
setCellContent(model, "C10", `=ODOO.PIVOT(1,"foo","#product_id",1)`);
setCellContent(model, "C11", `=ODOO.PIVOT(1,"foo","#product_id",2)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCellValue(model, "A10"), "xpad");
assert.strictEqual(getCellValue(model, "A11"), "xphone");
assert.strictEqual(getCellValue(model, "B10"), 121);
@@ -1,10 +1,8 @@
/** @odoo-module */
import { nextTick } from "@web/../tests/helpers/utils";
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
import { generateListDefinition } from "./data";
import { createModelWithDataSource } from "./model";
import { createModelWithDataSource, waitForDataSourcesLoaded } from "./model";
const uuidGenerator = new spreadsheet.helpers.UuidGenerator();
@@ -66,6 +64,6 @@ export async function createSpreadsheetWithList(params = {}) {
const env = model.config.evalContext.env;
env.model = model;
await nextTick();
await waitForDataSourcesLoaded(model);
return { model, env };
}
@@ -50,6 +50,23 @@ export async function createModelWithDataSource(params = {}) {
* @param {Model} model
*/
export async function waitForDataSourcesLoaded(model) {
function readAllCellsValue() {
for (const sheetId of model.getters.getSheetIds()) {
const cells = model.getters.getCells(sheetId);
for (const cellId in cells) {
cells[cellId].evaluated.value;
}
}
}
// Read a first time in order to trigger the RPC
readAllCellsValue();
//@ts-ignore
await model.config.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();
}
@@ -5,7 +5,7 @@ import { nextTick } from "@web/../tests/helpers/utils";
import PivotDataSource from "@spreadsheet/pivot/pivot_data_source";
import { getBasicServerData } from "./data";
import { createModelWithDataSource } from "./model";
import { createModelWithDataSource, waitForDataSourcesLoaded } from "./model";
/** @typedef {import("@spreadsheet/o_spreadsheet/o_spreadsheet").Model} Model */
@@ -70,5 +70,6 @@ export async function createSpreadsheetWithPivot(params = {}) {
await insertPivotInSpreadsheet(model, { arch });
const env = model.config.evalContext.env;
env.model = model;
await waitForDataSourcesLoaded(model);
return { model, env };
}
@@ -1,8 +1,10 @@
/** @odoo-module */
import { nextTick } from "@web/../tests/helpers/utils";
import { setCellContent } from "@spreadsheet/../tests/utils/commands";
import { createModelWithDataSource } from "@spreadsheet/../tests/utils/model";
import {
createModelWithDataSource,
waitForDataSourcesLoaded,
} from "@spreadsheet/../tests/utils/model";
import { getCellValue } from "@spreadsheet/../tests/utils/getters";
import { getAccountingData } from "../accounting_test_data";
@@ -16,21 +18,21 @@ QUnit.module("spreadsheet_account > account groups", { beforeEach }, () => {
QUnit.test("get no account", async (assert) => {
const model = await createModelWithDataSource({ serverData });
setCellContent(model, "A1", `=ODOO.ACCOUNT.GROUP("test")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(getCellValue(model, "A1"), "");
});
QUnit.test("get one account", async (assert) => {
const model = await createModelWithDataSource({ serverData });
setCellContent(model, "A1", `=ODOO.ACCOUNT.GROUP("income_other")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(getCellValue(model, "A1"), "100105");
});
QUnit.test("get multiple accounts", async (assert) => {
const model = await createModelWithDataSource({ serverData });
setCellContent(model, "A1", `=ODOO.ACCOUNT.GROUP("income")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(getCellValue(model, "A1"), "100104,200104");
});
});
@@ -1,8 +1,10 @@
/** @odoo-module */
import { nextTick } from "@web/../tests/helpers/utils";
import { setCellContent } from "@spreadsheet/../tests/utils/commands";
import { createModelWithDataSource } from "@spreadsheet/../tests/utils/model";
import {
createModelWithDataSource,
waitForDataSourcesLoaded,
} from "@spreadsheet/../tests/utils/model";
import { parseAccountingDate } from "../../src/accounting_functions";
import { getCellValue, getCell } from "@spreadsheet/../tests/utils/getters";
import { getAccountingData } from "../accounting_test_data";
@@ -29,7 +31,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
setCellContent(model, "A1", `=ODOO.CREDIT("100", "2022")`);
setCellContent(model, "A2", `=ODOO.DEBIT("100", "2022")`);
setCellContent(model, "A3", `=ODOO.BALANCE("100", "2022")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(getCellValue(model, "A1"), 16);
assert.equal(getCellValue(model, "A2"), 42);
assert.equal(getCellValue(model, "A3"), 26);
@@ -41,7 +43,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
setCellContent(model, "A1", `=ODOO.CREDIT("100", "2022")`);
setCellContent(model, "A2", `=ODOO.DEBIT("100", "2022")`);
setCellContent(model, "A3", `=ODOO.BALANCE("100", "2022")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(getCell(model, "A1").evaluated.format, "#,##0.00[$€]");
assert.strictEqual(getCell(model, "A2").evaluated.format, "#,##0.00[$€]");
assert.strictEqual(getCell(model, "A3").evaluated.format, "#,##0.00[$€]");
@@ -56,7 +58,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
},
});
setCellContent(model, "A1", `=ODOO.CREDIT("100", "2022", 0, 123456)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.strictEqual(
getCell(model, "A1").evaluated.error.message,
"Currency not available for this company."
@@ -72,12 +74,15 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
setCellContent(model, "A5", `=ODOO.BALANCE("100", 1900)`); // this should be ok
setCellContent(model, "A6", `=ODOO.BALANCE("100", 1900, -1)`);
setCellContent(model, "A7", `=ODOO.DEBIT("100", 1899)`);
await nextTick();
const errorMessage = `'%s' is not a valid period. Supported formats are "21/12/2022", "Q1/2022", "12/2022", and "2022".`
await waitForDataSourcesLoaded(model);
const errorMessage = `'%s' is not a valid period. Supported formats are "21/12/2022", "Q1/2022", "12/2022", and "2022".`;
assert.equal(getCell(model, "A1").evaluated.error.message, "0 is not a valid year.");
assert.equal(getCell(model, "A2").evaluated.error.message, "0 is not a valid year.");
assert.equal(getCell(model, "A3").evaluated.error.message, "-1 is not a valid year.");
assert.equal(getCell(model, "A4").evaluated.error.message, sprintf(errorMessage, "not a valid period"));
assert.equal(
getCell(model, "A4").evaluated.error.message,
sprintf(errorMessage, "not a valid period")
);
assert.equal(getCell(model, "A5").evaluated.value, 0);
assert.equal(getCell(model, "A6").evaluated.error.message, "1899 is not a valid year.");
assert.equal(getCell(model, "A7").evaluated.error.message, "1899 is not a valid year.");
@@ -98,7 +103,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
setCellContent(model, "A1", `=ODOO.CREDIT("100,200", "2022")`);
setCellContent(model, "A2", `=ODOO.DEBIT("100,200", "2022")`);
setCellContent(model, "A3", `=ODOO.BALANCE("100,200", "2022")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(getCellValue(model, "A1"), 26);
assert.equal(getCellValue(model, "A2"), 142);
assert.equal(getCellValue(model, "A3"), 116);
@@ -114,7 +119,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
},
});
setCellContent(model, "A1", `=ODOO.CREDIT("100", "2022")`);
await nextTick();
await waitForDataSourcesLoaded(model);
const cell = getCell(model, "A1");
assert.equal(cell.evaluated.value, "#ERROR");
assert.equal(cell.evaluated.error.message, "a nasty error");
@@ -125,7 +130,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
mockRPC: async function (route, args) {
if (args.method === "spreadsheet_fetch_debit_credit") {
const blobs = args.args[0];
for (let blob of blobs) {
for (const blob of blobs) {
assert.step(JSON.stringify(blob));
}
}
@@ -141,7 +146,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
setCellContent(model, "A7", `=ODOO.DEBIT("5", "05/04/2021", 1)`);
setCellContent(model, "A8", `=ODOO.BALANCE("5", "2022",,,FALSE)`);
setCellContent(model, "A9", `=ODOO.BALANCE("100", "05/05/2022",,,TRUE)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.verifySteps([
JSON.stringify(
@@ -217,7 +222,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
if (args.method === "spreadsheet_fetch_debit_credit") {
assert.step("spreadsheet_fetch_debit_credit");
const blobs = args.args[0];
for (let blob of blobs) {
for (const blob of blobs) {
assert.step(JSON.stringify(blob));
}
}
@@ -226,7 +231,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
setCellContent(model, "A1", `=ODOO.BALANCE("100,200", "2022")`);
setCellContent(model, "A2", `=ODOO.CREDIT("100,200", "2022")`);
setCellContent(model, "A3", `=ODOO.DEBIT("100,200","2022")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.verifySteps([
"spreadsheet_fetch_debit_credit",
@@ -256,7 +261,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
if (args.method === "spreadsheet_fetch_debit_credit") {
assert.step("spreadsheet_fetch_debit_credit");
const blobs = args.args[0];
for (let blob of blobs) {
for (const blob of blobs) {
assert.step(JSON.stringify(blob));
}
}
@@ -266,7 +271,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
setCellContent(model, "A2", `=ODOO.BALANCE(A1, 2022)`);
assert.equal(getCellValue(model, "A1"), "Loading...");
assert.equal(getCellValue(model, "A2"), "Loading...");
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(getCellValue(model, "A1"), "100104,200104");
assert.equal(getCellValue(model, "A2"), 0);
assert.verifySteps([
@@ -297,7 +302,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
if (args.method === "spreadsheet_fetch_debit_credit") {
assert.step("spreadsheet_fetch_debit_credit");
const blobs = args.args[0];
for (let blob of blobs) {
for (const blob of blobs) {
assert.step(JSON.stringify(blob));
}
}
@@ -313,7 +318,7 @@ QUnit.module("spreadsheet_account > Accounting", { beforeEach }, () => {
// Because cells are evaluated given their order in the sheet,
// A1's request is done first, meaning it's also resolved first, which add A2 to the next batch (synchronously)
// Only then A3 is resolved. => A2 is batched while A3 is pending
await nextTick();
await waitForDataSourcesLoaded(model);
assert.equal(getCellValue(model, "A1"), "100104,200104");
assert.equal(getCellValue(model, "A2"), 0);
assert.equal(getCellValue(model, "A3"), 0);
@@ -1,7 +1,9 @@
/** @odoo-module */
import { nextTick } from "@web/../tests/helpers/utils";
import { setCellContent } from "@spreadsheet/../tests/utils/commands";
import { createModelWithDataSource } from "@spreadsheet/../tests/utils/model";
import {
createModelWithDataSource,
waitForDataSourcesLoaded,
} from "@spreadsheet/../tests/utils/model";
import { getCell } from "@spreadsheet/../tests/utils/getters";
import "@spreadsheet_account/index";
@@ -25,7 +27,7 @@ QUnit.module("spreadsheet_account > fiscal year", {}, () => {
});
setCellContent(model, "A1", `=ODOO.FISCALYEAR.START("11/11/2020")`);
setCellContent(model, "A2", `=ODOO.FISCALYEAR.END("11/11/2020")`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.verifySteps(["get_fiscal_dates"]);
assert.equal(getCell(model, "A1").formattedValue, "1/1/2020");
assert.equal(getCell(model, "A2").formattedValue, "12/31/2020");
@@ -50,7 +52,7 @@ QUnit.module("spreadsheet_account > fiscal year", {}, () => {
});
setCellContent(model, "A1", `=ODOO.FISCALYEAR.START("11/11/2020", 1)`);
setCellContent(model, "A2", `=ODOO.FISCALYEAR.END("11/11/2020", 1)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.verifySteps(["get_fiscal_dates"]);
assert.equal(getCell(model, "A1").formattedValue, "1/1/2020");
assert.equal(getCell(model, "A2").formattedValue, "12/31/2020");
@@ -75,7 +77,7 @@ QUnit.module("spreadsheet_account > fiscal year", {}, () => {
});
setCellContent(model, "A1", `=ODOO.FISCALYEAR.START("11/11/2020", 100)`);
setCellContent(model, "A2", `=ODOO.FISCALYEAR.END("11/11/2020", 100)`);
await nextTick();
await waitForDataSourcesLoaded(model);
assert.verifySteps(["get_fiscal_dates"]);
assert.equal(
getCell(model, "A1").evaluated.error.message,
@@ -1,10 +1,12 @@
/** @odoo-module */
import { nextTick } from "@web/../tests/helpers/utils";
import { selectCell, setCellContent } from "@spreadsheet/../tests/utils/commands";
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
import { getAccountingData } from "../accounting_test_data";
import { createModelWithDataSource } from "@spreadsheet/../tests/utils/model";
import {
createModelWithDataSource,
waitForDataSourcesLoaded,
} from "@spreadsheet/../tests/utils/model";
import { registry } from "@web/core/registry";
const { cellMenuRegistry } = spreadsheet.registries;
@@ -64,7 +66,7 @@ QUnit.module("spreadsheet_account > Accounting Drill down", { beforeEach }, () =
env.model = model;
setCellContent(model, "A1", `=ODOO.BALANCE("100", 2020)`);
setCellContent(model, "A2", `=ODOO.BALANCE("100", 0)`);
await nextTick();
await waitForDataSourcesLoaded(model);
selectCell(model, "A1");
const root = cellMenuRegistry.getAll().find((item) => item.id === "move_lines_see_records");
assert.equal(root.isVisible(env), true);