[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) <aab@odoo.com>
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
This commit is contained in:
MerlinGuillaume
2023-10-12 11:20:34 +00:00
parent 3463c48cad
commit af73206892
2 changed files with 39 additions and 1 deletions
@@ -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.");
}
@@ -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: `
<form>
<group>
<label for="foo"/>
<div><field name="foo" help="foo xml tooltip"/></div>
<label for="bar"/>
<div><field name="bar" help="bar xml tooltip"/></div>
</group>
</form>`,
});
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",