diff options
| author | Mathieu Duckerts-Antoine <dam@odoo.com> | 2021-02-10 15:17:33 +0000 |
|---|---|---|
| committer | Mathieu Duckerts-Antoine <dam@odoo.com> | 2021-02-12 09:22:50 +0000 |
| commit | ad5d642c455d3215857f25e0d69c593324178d29 (patch) | |
| tree | a8f1c0a15c2686d8bf1cede5f7e21f036170809f /addons/web/static | |
| parent | 850581c49c84042bd5b40b632798c56789a1c60e (diff) | |
[FIX] web: boolean field autocompletion with 'No'
Before this commit, select the "No" option of a boolean field in the
search bar autocompletion menu would crash.
closes odoo/odoo#65896
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static')
| -rw-r--r-- | addons/web/static/src/js/control_panel/search_bar.js | 2 | ||||
| -rw-r--r-- | addons/web/static/tests/control_panel/search_bar_tests.js | 17 |
2 files changed, 16 insertions, 3 deletions
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 0dc8599c4ab..c3f8d1ec4d6 100644 --- a/addons/web/static/src/js/control_panel/search_bar.js +++ b/addons/web/static/src/js/control_panel/search_bar.js @@ -278,7 +278,7 @@ odoo.define('web.SearchBar', function (require) { const labelValue = source.label || this.state.inputValue; this.model.dispatch('addAutoCompletionValues', { filterId: source.filterId, - value: source.value || this._parseWithSource(labelValue, source), + value: "value" in source ? source.value : this._parseWithSource(labelValue, source), label: labelValue, operator: source.filterOperator || source.operator, }); 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 ee28b9f43ce..5eaf2287f8d 100644 --- a/addons/web/static/tests/control_panel/search_bar_tests.js +++ b/addons/web/static/tests/control_panel/search_bar_tests.js @@ -571,8 +571,8 @@ odoo.define('web.search_bar_tests', function (require) { actionManager.destroy(); }); - QUnit.test('autocomplete a boolean value', async function (assert) { - assert.expect(5); + QUnit.test('autocompletion with a boolean field', async function (assert) { + assert.expect(9); this.archs['partner,false,search'] = '<search><field name="bool"/></search>'; @@ -598,9 +598,22 @@ odoo.define('web.search_bar_tests', function (require) { // select "Yes" await testUtils.dom.click(actionManager.el.querySelector('.o_searchview_autocomplete li:last-child')); + await cpHelpers.removeFacet(actionManager, 0); + + await cpHelpers.editSearch(actionManager, "No"); + + assert.containsN(actionManager, '.o_searchview_autocomplete li', 2); + assert.strictEqual(actionManager.$('.o_searchview_autocomplete li:last-child').text(), "No"); + + // select "No" + await testUtils.dom.click(actionManager.el.querySelector('.o_searchview_autocomplete li:last-child')); + + assert.verifySteps([ JSON.stringify([]), // initial search JSON.stringify([["bool", "=", true]]), + JSON.stringify([]), + JSON.stringify([["bool", "=", false]]), ]); actionManager.destroy(); |
