From e42175c1d5d79c45cfcb53c2937458cc1404c5cd Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Mon, 7 Nov 2022 14:31:55 +0000 Subject: [PATCH] [FIX] web: settings_form_compiler, copy all attributes to the labels Before this commit, the labels tags that were after the fields losses their attributes (i.e. classes) after the compilation of the form view arch. Now, the attributes are correctly copied after the compilation. similar to : 873790f80270490cceb55129516b0c9af049d23d X-original-commit: 395bdf8880c5929652838a93351596b045708905 Part-of: odoo/odoo#105315 Co-authored-by: Patrick Hoste --- .../settings_form_compiler.js | 2 +- .../settings_form_view_tests.js | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/webclient/settings_form_view/settings_form_compiler.js b/addons/web/static/src/webclient/settings_form_view/settings_form_compiler.js index 063d9bf11ae..94247c3510f 100644 --- a/addons/web/static/src/webclient/settings_form_view/settings_form_compiler.js +++ b/addons/web/static/src/webclient/settings_form_view/settings_form_compiler.js @@ -177,7 +177,7 @@ export class SettingsFormCompiler extends FormCompiler { { selector: "h2", fn: compileSettingsGroupTitle }, { selector: "h3.o_setting_tip", fn: compileSettingsGroupTip }, // search terms and highlight : - { selector: "label", fn: compileLabel }, + { selector: "label", fn: compileLabel, doNotCopyAttributes: true }, { selector: "span.o_form_label", fn: compileGenericLabel }, { selector: "div.text-muted", fn: compileGenericLabel }, { selector: "field", fn: compileField } diff --git a/addons/web/static/tests/webclient/settings_form_view/settings_form_view_tests.js b/addons/web/static/tests/webclient/settings_form_view/settings_form_view_tests.js index d715da92c40..82188392611 100644 --- a/addons/web/static/tests/webclient/settings_form_view/settings_form_view_tests.js +++ b/addons/web/static/tests/webclient/settings_form_view/settings_form_view_tests.js @@ -508,6 +508,34 @@ QUnit.module("SettingsFormView", (hooks) => { await nextTick(); }); + QUnit.test("correctly copy attributes to compiled labels", async function (assert) { + await makeView({ + type: "form", + resModel: "res.config.settings", + serverData, + arch: ` +
+
+
+
+
+
+
+
+
+
+
+
`, + }); + + assert.hasClass(target.querySelectorAll(".o_form_label")[0], "a"); + assert.hasClass(target.querySelector(".o_field_widget.o_field_boolean"), "b"); + assert.hasClass(target.querySelectorAll(".o_form_label")[1], "c"); + }); + QUnit.test("settings views does not write the id on the url", async function (assert) { serverData.actions = { 1: {