Skip to content

Commit ebb2d54

Browse files
committed
[FIX] table: create dynamic table on #SPILL! errors
Steps to reproduce: - add an array formula - add some content on the spill zone - select the cell with #SPILL! error - add a table on that cell => the created table is not dynamic closes #7263 Task: 5102771 Signed-off-by: Adrien Minne (adrm) <adrm@odoo.com>
1 parent fb62e04 commit ebb2d54

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/plugins/ui_core_views/dynamic_tables.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
zoneToXc,
1010
} from "../../helpers";
1111
import { createFilter } from "../../helpers/table_helpers";
12+
import { CellErrorType } from "../../types/errors";
1213
import {
1314
CellPosition,
1415
Command,
@@ -170,7 +171,10 @@ export class DynamicTablesPlugin extends CoreViewPlugin {
170171

171172
const parentSpreadingCell = this.getters.getArrayFormulaSpreadingOn(topLeft);
172173
if (!parentSpreadingCell) {
173-
return false;
174+
const evaluatedCell = this.getters.getEvaluatedCell(topLeft);
175+
return (
176+
evaluatedCell.value === CellErrorType.SpilledBlocked && !evaluatedCell.errorOriginPosition
177+
);
174178
} else if (deepEquals(parentSpreadingCell, topLeft) && getZoneArea(unionZone) === 1) {
175179
return true;
176180
}

tests/menus/menu_items_registry.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,29 @@ describe("Menu Item actions", () => {
16741674
});
16751675
});
16761676

1677+
test("Insert -> Table creates a dynamic table if it's called on a #SPILL! error", () => {
1678+
setCellContent(model, "A1", "=MUNIT(500)");
1679+
setSelection(model, ["A1"]);
1680+
expect(getEvaluatedCell(model, "A1")?.value).toBe("#SPILL!");
1681+
doAction(insertTablePath, env);
1682+
expect(model.getters.getCoreTable({ sheetId, row: 0, col: 0 })).toMatchObject({
1683+
range: { zone: toZone("A1") },
1684+
type: "dynamic",
1685+
});
1686+
});
1687+
1688+
test("Insert -> Table do not creates a dynamic table if it's called on cell referencing a #SPILL! error", () => {
1689+
setCellContent(model, "A1", "=A3");
1690+
setCellContent(model, "A3", "=MUNIT(500)");
1691+
expect(getEvaluatedCell(model, "A1")?.value).toBe("#SPILL!");
1692+
setSelection(model, ["A1"]);
1693+
doAction(insertTablePath, env);
1694+
expect(model.getters.getCoreTable({ sheetId, row: 0, col: 0 })).toMatchObject({
1695+
range: { zone: toZone("A1") },
1696+
type: "static",
1697+
});
1698+
});
1699+
16771700
test("Edit -> Table (topbar)", () => {
16781701
const spyOpenSidePanel = jest.spyOn(env, "openSidePanel");
16791702
createTable(model, "A1:A5");

0 commit comments

Comments
 (0)