[FIX] web: FormView with OuterGroup empty

Before this commit, if a form view has a group containing only invisible
elements and at least one invisible group, then the view crashes.

Example:
    <form>
        <sheet>
            <group>
                <group invisible="1">
                    <field name="foo"/>
                </group>
            </group>
        </sheet>
    </form>

The solution is to have an empty list as the default props for the
OuterGroup slots. OuterGroup is a group containing at least one other group.

closes odoo/odoo#97295

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
FrancoisGe
2022-08-04 11:45:28 +02:00
parent 9569438643
commit 054c2f21df
2 changed files with 25 additions and 0 deletions
@@ -31,6 +31,10 @@ export class OuterGroup extends Group {
}
}
OuterGroup.template = "web.Form.OuterGroup";
OuterGroup.defaultProps = {
...Group.defaultProps,
slots: [],
};
export class InnerGroup extends Group {
getRows() {
@@ -299,6 +299,27 @@ QUnit.module("Views", (hooks) => {
assert.containsNone(target, "label.o_form_label_empty:contains(timmy)");
});
QUnit.test("form view with a group that contains an invisible group", async function (assert) {
await makeView({
type: "form",
resModel: "partner",
serverData,
arch: `
<form>
<sheet>
<group>
<group invisible="1">
<field name="foo"/>
</group>
</group>
</sheet>
</form>`,
resId: 2,
});
assert.containsOnce(target, ".o_form_view .o_group");
});
QUnit.test("status bar rendering without buttons", async (assert) => {
await makeView({
type: "form",