[FIX] web: field help attribute in xml has precedence
Have a field declared in python with a "help" property. Put that field in a view with a "help" attribute. Before this commit, the xml declaration was not taken into account. After this commit, xml declaration has precedence over the python one. closes odoo/odoo#97782 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -203,6 +203,7 @@ Field.parseFieldNode = function (node, models, modelName, viewType, jsClass) {
|
||||
context: node.getAttribute("context") || "{}",
|
||||
domain: node.getAttribute("domain") || "[]",
|
||||
string: node.getAttribute("string") || field.string,
|
||||
help: node.getAttribute("help"),
|
||||
widget,
|
||||
modifiers,
|
||||
onChange: archParseBoolean(node.getAttribute("on_change")),
|
||||
|
||||
@@ -20,7 +20,7 @@ export function getTooltipInfo(params) {
|
||||
field: {
|
||||
label: params.field.string,
|
||||
name: params.field.name,
|
||||
help: params.help || params.field.help,
|
||||
help: params.fieldInfo.help !== null ? params.fieldInfo.help : params.field.help,
|
||||
type: params.field.type,
|
||||
widget: params.fieldInfo.widget,
|
||||
widgetDescription,
|
||||
|
||||
@@ -11716,4 +11716,21 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.verifySteps(["get_views", "onchange", "onchange", "create", "read", "read"]);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("help on field as precedence over field's declaration -- form", async (assert) => {
|
||||
serverData.models.partner.fields.foo.help = "pythonHelp";
|
||||
patchWithCleanup(odoo, { debug: "1" });
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
arch: `<form><sheet><field name="foo" help="xmlHelp" /></sheet></form>`,
|
||||
serverData,
|
||||
});
|
||||
|
||||
assert.strictEqual(
|
||||
JSON.parse(target.querySelector(".o_field_widget").dataset.tooltipInfo).field.help,
|
||||
"xmlHelp"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user