diff --git a/addons/web/static/src/views/form/form_compiler.js b/addons/web/static/src/views/form/form_compiler.js index 5683314e02b..0e4fdc572da 100644 --- a/addons/web/static/src/views/form/form_compiler.js +++ b/addons/web/static/src/views/form/form_compiler.js @@ -123,12 +123,13 @@ export class FormCompiler extends ViewCompiler { el.classList.remove("oe_button_box"); const buttonBox = createElement("ButtonBox"); let slotId = 0; - + let hasContent = false; for (const child of el.children) { const invisible = getModifier(child, "invisible"); if (isAlwaysInvisible(invisible, params)) { continue; } + hasContent = true; const mainSlot = createElement("t", { "t-set-slot": `slot_${slotId++}`, isVisible: @@ -140,7 +141,7 @@ export class FormCompiler extends ViewCompiler { append(buttonBox, mainSlot); } - return buttonBox; + return hasContent ? buttonBox : null; } /** diff --git a/addons/web/static/tests/views/form/form_view_tests.js b/addons/web/static/tests/views/form/form_view_tests.js index adcbdec4397..2581a4fd377 100644 --- a/addons/web/static/tests/views/form/form_view_tests.js +++ b/addons/web/static/tests/views/form/form_view_tests.js @@ -5721,6 +5721,22 @@ QUnit.module("Views", (hooks) => { ); }); + QUnit.test("empty button box", async function (assert) { + await makeView({ + type: "form", + resModel: "partner", + serverData, + arch: ` +
`, + resId: 2, + }); + + assert.containsNone(target, ".o-form-buttonbox"); + }); + QUnit.test("one2many default value creation", async function (assert) { assert.expect(1);