[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#66058

X-original-commit: ad5d642c455d3215857f25e0d69c593324178d29
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Mathieu Duckerts-Antoine
2021-02-12 12:02:43 +00:00
parent 9580b2607c
commit 862b21f156
2 changed files with 16 additions and 3 deletions
@@ -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,
});
@@ -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();