From a7657fbf847e2c1aa5104237cb2c4ddee79318ab Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Mon, 6 Jul 2020 09:02:03 +0000 Subject: [PATCH] [IMP] web: Drop widget support in search view Until now the "widget" attribute used in the search view was meant to force the type of a field regardless of its definition. This system was implemented quite a long time ago and is now useful in only one case: searching for "reference" fields (we want them considered as char fields else it is impossible to search on them). This is why this commit completely removes the "widget" attribute support in search views while consistently casting the "reference" fields as "char" fields in the search bar. Task 2061795 --- .../src/js/control_panel/control_panel_model_extension.js | 3 --- addons/web/static/src/js/control_panel/search_bar.js | 2 +- addons/web/static/tests/control_panel/search_bar_tests.js | 4 ++-- doc/reference/views.rst | 4 ---- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/js/control_panel/control_panel_model_extension.js b/addons/web/static/src/js/control_panel/control_panel_model_extension.js index ef443fbb70a..2b12ca90802 100644 --- a/addons/web/static/src/js/control_panel/control_panel_model_extension.js +++ b/addons/web/static/src/js/control_panel/control_panel_model_extension.js @@ -916,9 +916,6 @@ odoo.define("web/static/src/js/control_panel/control_panel_model_extension.js", filter.defaultRank = -10; filter.defaultAutocompleteValue = attrs.defaultAutocompleteValue; } - if (attrs.widget) { - filter.widget = attrs.widget; - } break; } } diff --git a/addons/web/static/src/js/control_panel/search_bar.js b/addons/web/static/src/js/control_panel/search_bar.js index 22f6ee6a60b..0dc8599c4ab 100644 --- a/addons/web/static/src/js/control_panel/search_bar.js +++ b/addons/web/static/src/js/control_panel/search_bar.js @@ -93,7 +93,7 @@ odoo.define('web.SearchBar', function (require) { */ _createSource(filter) { const field = this.props.fields[filter.fieldName]; - const type = filter.widget || field.type; + const type = field.type === "reference" ? "char" : field.type; const source = { active: true, description: filter.description, diff --git a/addons/web/static/tests/control_panel/search_bar_tests.js b/addons/web/static/tests/control_panel/search_bar_tests.js index b7f5fc8956d..655464cac1f 100644 --- a/addons/web/static/tests/control_panel/search_bar_tests.js +++ b/addons/web/static/tests/control_panel/search_bar_tests.js @@ -538,7 +538,7 @@ odoo.define('web.search_bar_tests', function (require) { actionManager.destroy(); }); - QUnit.test("widgets are supported in search view", async function (assert) { + QUnit.test("reference fields are supported in search view", async function (assert) { assert.expect(7); this.data.partner.fields.ref = { type: 'reference', string: "Reference" }; @@ -548,7 +548,7 @@ odoo.define('web.search_bar_tests', function (require) { const archs = Object.assign({}, this.archs, { 'partner,false,search': ` - + `, }); const actionManager = await createActionManager({ diff --git a/doc/reference/views.rst b/doc/reference/views.rst index dfb01447cf9..09091451e9e 100644 --- a/doc/reference/views.rst +++ b/doc/reference/views.rst @@ -1856,10 +1856,6 @@ Possible children elements of the search view are: ``filter_domain="[]"`` ``groups`` make the field only available to specific users - ``widget`` - use specific search widget for the field (the only use case in - standard Odoo 8.0 is a ``selection`` widget for - :class:`~odoo.fields.Many2one` fields) ``domain`` if the field can provide an auto-completion (e.g. :class:`~odoo.fields.Many2one`), filters the possible