[FIX] spreadsheet_account: Fix see records action

The `see records` action that drill downs to the specific AccountMoveLines
that match the formula domain would  break if we left some optional
formula arguments empty (specifically concerns the offset and companyId
arguments). This revision ensures that we use their default value when the
arguments are not provided.

closes odoo/odoo#151423

Task: 3621110
X-original-commit: 23bbb0cdebc9028fcc93e006e755c43000428fcb
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
Rémi Rahir (rar)
2024-01-29 23:16:17 +00:00
parent 59813f0cff
commit b8dbec3b11
2 changed files with 18 additions and 3 deletions
@@ -27,9 +27,14 @@ cellMenuRegistry.add("move_lines_see_records", {
codes = toString(codes).split(",");
const locale = env.model.getters.getLocale();
const dateRange = parseAccountingDate(date_range, locale);
offset = parseInt(offset) || 0;
dateRange.year += offset || 0;
companyId = companyId || null;
includeUnposted = toBoolean(includeUnposted);
companyId = parseInt(companyId) || null;
try {
includeUnposted = toBoolean(includeUnposted);
} catch {
includeUnposted = false;
}
const action = await env.services.orm.call(
"account.account",
@@ -66,8 +66,10 @@ 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)`);
setCellContent(model, "A3", `=ODOO.BALANCE("100", 2020, , , FALSE)`);
setCellContent(model, "A4", `=ODOO.BALANCE("100", 2020, , , )`);
// Does not affect non formula cells
setCellContent(model, "A4", `5`);
setCellContent(model, "A5", `5`);
await waitForDataSourcesLoaded(model);
selectCell(model, "A1");
const root = cellMenuRegistry
@@ -78,7 +80,15 @@ QUnit.module("spreadsheet_account > Accounting Drill down", { beforeEach }, () =
assert.verifySteps(["drill down action"]);
selectCell(model, "A2");
assert.equal(root.isVisible(env), false);
selectCell(model, "A3");
assert.equal(root.isVisible(env), true);
await root.execute(env);
assert.verifySteps(["drill down action"]);
selectCell(model, "A4");
assert.equal(root.isVisible(env), true);
await root.execute(env);
assert.verifySteps(["drill down action"]);
selectCell(model, "A5");
assert.equal(root.isVisible(env), false);
});
});