From af73206892fce2758fcb9b691a899be7f4ef83c4 Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Fri, 6 Oct 2023 09:46:28 +0200 Subject: [PATCH] [FIX] web: add help tooltip from form view on fields The help defined on a field via Studio is only visible when debug mode is enabled Steps to reproduce: 1. Install Contacts and Studio 2. Go to Contacts, open a contact and toggle Studio 3. Add a field in the form view and add a message in the Help Tooltip of the field 4. Close Studio 5. Without debug mode, the small question mark is not displayed next to the field so we cannot see the help tooltip Solution: First use the help defined on the field in the view, then the help defined on the field in the model Problem: The tooltip help can also come from the view opw-3511121 closes odoo/odoo#138416 X-original-commit: a70639b790471aec781c50274abbda78bf5bea7d Signed-off-by: Aaron Bohy (aab) Signed-off-by: Guillaume Merlin (megu) --- .../web/static/src/views/form/form_label.js | 2 +- .../tests/views/form/form_view_tests.js | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/form/form_label.js b/addons/web/static/src/views/form/form_label.js index 408b9241219..ed4c36a3935 100644 --- a/addons/web/static/src/views/form/form_label.js +++ b/addons/web/static/src/views/form/form_label.js @@ -33,7 +33,7 @@ export class FormLabel extends Component { get tooltipHelp() { const field = this.props.record.fields[this.props.fieldName]; - let help = field.help || ""; + let help = this.props.fieldInfo.help || field.help || ""; if (field.company_dependent && session.display_switch_company_menu) { help += (help ? "\n\n" : "") + _t("Values set here are company-specific."); } 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 3485b095451..045738aa365 100644 --- a/addons/web/static/tests/views/form/form_view_tests.js +++ b/addons/web/static/tests/views/form/form_view_tests.js @@ -13014,6 +13014,44 @@ QUnit.module("Views", (hooks) => { ); }); + QUnit.test("help on field is shown without debug mode -- form", async (assert) => { + serverData.models.partner.fields.bar.help = "bar tooltip"; + + patchWithCleanup(browser, { + setTimeout: (fn) => fn(), + clearTimeout: () => { }, + }); + + await makeView({ + type: "form", + resModel: "partner", + serverData, + arch: ` +
+ + +
`, + }); + + await mouseEnter(target.querySelector(".o_form_label[for=foo_0] sup")); + await nextTick(); + assert.strictEqual( + target.querySelector(".o-tooltip .o-tooltip--help").textContent, + "foo xml tooltip" + ); + + await mouseEnter(target.querySelector(".o_form_label[for=bar_0] sup")); + await nextTick(); + assert.strictEqual( + target.querySelector(".o-tooltip .o-tooltip--help").textContent, + "bar xml tooltip" + ); + }); + QUnit.test("onSave/onDiscard props", async function (assert) { await makeView({ type: "form",