From 9569438643e9cd768043a090ba1bfc85af78a5bc Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Tue, 2 Aug 2022 13:55:08 +0000 Subject: [PATCH] [FIX] web: filter_domain with an integer value Before this commit, an error was returned when opening a view if the view's searchArch contained a field with a filter_domain and the view's context contained an integer "search_default_" for that field. Example: context: { search_default_m2o: 1, } Part-of: odoo/odoo#97295 --- .../static/src/search/search_arch_parser.js | 2 +- .../web/static/tests/views/list_view_tests.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/search/search_arch_parser.js b/addons/web/static/src/search/search_arch_parser.js index 9883356f40d..140a289937b 100644 --- a/addons/web/static/src/search/search_arch_parser.js +++ b/addons/web/static/src/search/search_arch_parser.js @@ -153,7 +153,7 @@ export class SearchArchParser extends XMLParser { preField.defaultRank = -10; const { fieldType, fieldName } = preField; const { selection, context, relation } = this.fields[fieldName]; - preField.defaultAutocompleteValue = { label: value, operator, value }; + preField.defaultAutocompleteValue = { label: `${value}`, operator, value }; if (fieldType === "selection") { const option = selection.find((sel) => sel[0] === value); if (!option) { diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index f185613210f..a00516381e8 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -14579,4 +14579,22 @@ QUnit.module("Views", (hooks) => { ); } ); + + QUnit.test("use a filter_domain in a list view", async function (assert) { + await makeView({ + type: "list", + resModel: "foo", + serverData, + arch: '', + searchViewArch: ` + + + `, + context: { + search_default_m2o: 1, + }, + }); + + assert.containsN(target, ".o_data_row", 3); + }); });