From 719e040dee8d7c319eb77f61893fd8eb8b7f4636 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 1 Jun 2017 16:01:54 +0200 Subject: [FIX] web: Many2One: search with input's value When the user writes something in a Many2One input, after a short delay, a name_search RPC is done with the value written in the input, and results are displayed in a dropdown. Then, if the user clicks on the input, the dropdown closes. If he clicks again, it should do again a name_search RPC with the value of the input. Before this rev., it was doing it with the empty string. --- addons/web/static/src/js/fields/relational_fields.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index a5f9b443ae0..d825f46b62b 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -105,7 +105,9 @@ var FieldMany2One = AbstractField.extend({ this.recordParams = {fieldName: this.name, viewType: this.viewType}; }, start: function () { - // what is 'this.floating' for? add a comment! + // booleean indicating that the content of the input isn't synchronized + // with the current m2o value (for instance, the user is currently + // typing something in the input, and hasn't selected a value yet). this.floating = false; this.$input = this.$('input'); @@ -453,8 +455,10 @@ var FieldMany2One = AbstractField.extend({ _onInputClick: function () { if (this.$input.autocomplete("widget").is(":visible")) { this.$input.autocomplete("close"); + } else if (this.floating) { + this.$input.autocomplete("search"); // search with the input's content } else { - this.$input.autocomplete("search", ""); + this.$input.autocomplete("search", ''); // search with the empty string } }, /** -- cgit v1.2.3