diff --git a/addons/web/static/src/views/form/form_compiler.js b/addons/web/static/src/views/form/form_compiler.js index cfdc71d85dd..bed508d254d 100644 --- a/addons/web/static/src/views/form/form_compiler.js +++ b/addons/web/static/src/views/form/form_compiler.js @@ -79,13 +79,14 @@ export class FormCompiler extends ViewCompiler { fieldInfo: `props.archInfo.fieldNodes['${fieldId}']`, className: `"${label.className}"`, }; - if (label.hasAttribute("data-no-label")) { - return; - } let labelText = label.textContent || fieldString; - labelText = labelText - ? toStringExpression(labelText) - : `props.record.fields['${fieldName}'].string`; + if (label.hasAttribute("data-no-label")) { + labelText = toStringExpression(""); + } else { + labelText = labelText + ? toStringExpression(labelText) + : `props.record.fields['${fieldName}'].string`; + } const formLabel = createElement("FormLabel", { "t-props": objectToString(props), string: labelText, diff --git a/addons/web/static/tests/views/form/form_compiler_tests.js b/addons/web/static/tests/views/form/form_compiler_tests.js index 3f4a09d60fe..93a85da3e7c 100644 --- a/addons/web/static/tests/views/form/form_compiler_tests.js +++ b/addons/web/static/tests/views/form/form_compiler_tests.js @@ -41,16 +41,20 @@ QUnit.module("Form Compiler", () => { assert.areEquivalent(compileTemplate(arch), expected); }); - QUnit.test("label with empty string is not rendered", async (assert) => { - const arch = /*xml*/ `