From 23611e65faacf2cd3e4be0f07a9fd564528eeed5 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 15 Dec 2023 09:41:51 +0000 Subject: [PATCH] [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) Signed-off-by: Aaron Bohy (aab) --- .../static/src/views/fields/field_tooltip.js | 2 +- .../static/src/views/fields/field_tooltip.xml | 10 +-- .../tests/views/form/form_view_tests.js | 71 ++++++++++++++++++- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/views/fields/field_tooltip.js b/addons/web/static/src/views/fields/field_tooltip.js index 7c673a24f2d..e17e28b438e 100644 --- a/addons/web/static/src/views/fields/field_tooltip.js +++ b/addons/web/static/src/views/fields/field_tooltip.js @@ -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, diff --git a/addons/web/static/src/views/fields/field_tooltip.xml b/addons/web/static/src/views/fields/field_tooltip.xml index f6b9f60bc63..99468981daa 100644 --- a/addons/web/static/src/views/fields/field_tooltip.xml +++ b/addons/web/static/src/views/fields/field_tooltip.xml @@ -38,21 +38,21 @@
  • Domain: - +
  • -
  • +
  • Invisible:
  • -
  • +
  • Column invisible:
  • -
  • +
  • Required:
  • -
  • +
  • Readonly:
  • 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 8d11d848c51..c3141979036 100644 --- a/addons/web/static/tests/views/form/form_view_tests.js +++ b/addons/web/static/tests/views/form/form_view_tests.js @@ -10733,7 +10733,7 @@ QUnit.module("Views", (hooks) => { arch: `
    - +
    `, }); @@ -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: ` +
    + + + +
    `, + }); + + 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: ` +
    + + + +
    `, + }); + + 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",