From 7e85786b8389993fa5bd3a0be68343ad0dbaa187 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux <jba@odoo.com> Date: Fri, 20 Jun 2014 16:10:02 +0200 Subject: [PATCH] web: do not select the first result if click on search more When searching for a record in a m2o field, if we click on 'search more' we loose the focus on the field and select the first suggestion (which triggers potential on_change). This prevents the selection for this case. --- addons/web/static/src/js/view_form.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index cbaf9e6f11e4..50ec791b7c7c 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3076,6 +3076,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this.floating = false; this.current_display = null; this.is_started = false; + this.ignore_focusout = false; }, reinit_value: function(val) { this.internal_set_value(val); @@ -3201,6 +3202,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc var ed_delay = 200; var ed_duration = 15000; var anyoneLoosesFocus = function (e) { + if (self.ignore_focusout) { return; } var used = false; if (self.floating) { if (self.last_search.length > 0) { @@ -3393,7 +3395,12 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc _search_create_popup: function() { this.no_ed = true; this.ed_def.reject(); - return instance.web.form.CompletionFieldMixin._search_create_popup.apply(this, arguments); + this.ignore_focusout = true; + this.reinit_value(false); + var res = instance.web.form.CompletionFieldMixin._search_create_popup.apply(this, arguments); + this.ignore_focusout = false; + this.no_ed = false; + return res; }, set_dimensions: function (height, width) { this._super(height, width); -- GitLab