[FIX] web: correctly display domain in field tooltip (debug)
This commit fixes 3 issues with the domain in field tooltips, in debug mode. 1) it only displayed the domain defined on the field in the model, not the domain set in attrs in the view, if any. 2) when the domain was the empty array, `domain: ` was displayed. 3) unset values should not appear in the tooltip (invisible, column_invisible, required, readonly). opw 3455119 closes odoo/odoo#146563 X-original-commit: 8c4ff1fac9eb003c23770bf74f9d7ffe062f6ce7 Signed-off-by: Francois Georis (fge) <fge@odoo.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -17,7 +17,7 @@ export function getTooltipInfo(params) {
|
||||
widget: params.fieldInfo.widget,
|
||||
widgetDescription,
|
||||
context: params.fieldInfo.context,
|
||||
domain: params.field.domain,
|
||||
domain: params.fieldInfo.domain || params.field.domain,
|
||||
invisible: params.fieldInfo.invisible,
|
||||
column_invisible: params.fieldInfo.column_invisible,
|
||||
readonly: params.fieldInfo.readonly,
|
||||
|
||||
@@ -38,21 +38,21 @@
|
||||
</li>
|
||||
<li t-if="field.domain" data-item="domain">
|
||||
<span class="o-tooltip--technical--title">Domain:</span>
|
||||
<t t-esc="field.domain"/>
|
||||
<t t-esc="field.domain.length === 0 ? '[]' : field.domain"/>
|
||||
</li>
|
||||
<li t-if="'invisible' in field" data-item="invisible">
|
||||
<li t-if="field.invisible" data-item="invisible">
|
||||
<span class="o-tooltip--technical--title">Invisible:</span>
|
||||
<t t-esc="field.invisible"/>
|
||||
</li>
|
||||
<li t-if="'column_invisible' in field" data-item="column_invisible">
|
||||
<li t-if="field.column_invisible" data-item="column_invisible">
|
||||
<span class="o-tooltip--technical--title">Column invisible:</span>
|
||||
<t t-esc="field.column_invisible"/>
|
||||
</li>
|
||||
<li t-if="'required' in field" data-item="required">
|
||||
<li t-if="field.required" data-item="required">
|
||||
<span class="o-tooltip--technical--title">Required:</span>
|
||||
<t t-esc="field.required"/>
|
||||
</li>
|
||||
<li t-if="'readonly' in field" data-item="readonly">
|
||||
<li t-if="field.readonly" data-item="readonly">
|
||||
<span class="o-tooltip--technical--title">Readonly:</span>
|
||||
<t t-esc="field.readonly"/>
|
||||
</li>
|
||||
|
||||
@@ -10733,7 +10733,7 @@ QUnit.module("Views", (hooks) => {
|
||||
arch: `
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="product_id" context="{'lang': 'en_US'}" invisible="product_id == 33" widget="many2one"/>
|
||||
<field name="product_id" domain="[]" context="{'lang': 'en_US'}" invisible="product_id == 33" widget="many2one"/>
|
||||
</sheet>
|
||||
</form>`,
|
||||
});
|
||||
@@ -10751,6 +10751,17 @@ QUnit.module("Views", (hooks) => {
|
||||
"{'lang': 'en_US'}",
|
||||
"context should be properly stringified"
|
||||
);
|
||||
assert.containsOnce(
|
||||
target,
|
||||
".o-tooltip--technical > li[data-item='domain']",
|
||||
"domain should be present for this field"
|
||||
);
|
||||
assert.strictEqual(
|
||||
target.querySelector('.o-tooltip--technical > li[data-item="domain"]').lastChild
|
||||
.textContent,
|
||||
"[]",
|
||||
"domain should be properly stringified"
|
||||
);
|
||||
assert.containsOnce(
|
||||
target,
|
||||
".o-tooltip--technical > li[data-item='invisible']",
|
||||
@@ -10775,6 +10786,64 @@ QUnit.module("Views", (hooks) => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("field tooltip in debug mode, on field with domain attr", async function (assert) {
|
||||
patchWithCleanup(odoo, { debug: true });
|
||||
|
||||
patchWithCleanup(browser, {
|
||||
setTimeout: (fn) => fn(),
|
||||
clearTimeout: () => {},
|
||||
});
|
||||
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="product_id" domain="[['id', '>', 3]]"/>
|
||||
</sheet>
|
||||
</form>`,
|
||||
});
|
||||
|
||||
await mouseEnter(target.querySelector("[name='product_id']"));
|
||||
await nextTick();
|
||||
assert.containsOnce(target, ".o-tooltip--technical > li[data-item='domain']");
|
||||
assert.strictEqual(
|
||||
target.querySelector('.o-tooltip--technical > li[data-item="domain"]').lastChild
|
||||
.textContent,
|
||||
"[['id', '>', 3]]"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("do not display unset attributes in debug field tooltip", async function (assert) {
|
||||
patchWithCleanup(odoo, { debug: true });
|
||||
|
||||
patchWithCleanup(browser, {
|
||||
setTimeout: (fn) => fn(),
|
||||
clearTimeout: () => {},
|
||||
});
|
||||
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="product_id"/>
|
||||
</sheet>
|
||||
</form>`,
|
||||
});
|
||||
|
||||
await mouseEnter(target.querySelector("[name='product_id']"));
|
||||
await nextTick();
|
||||
assert.deepEqual(
|
||||
getNodesTextContent(target.querySelectorAll(".o-tooltip--technical > li")),
|
||||
["Field:product_id", "Type:many2one", "Context:{}", "Relation:product"]
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("do not change pager when discarding current record", async function (assert) {
|
||||
await makeView({
|
||||
type: "form",
|
||||
|
||||
Reference in New Issue
Block a user