From b95b4035e4d05b1ac6fb0b1d9b0c3567b07344d2 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Fri, 3 Aug 2018 16:09:08 +0200 Subject: [FIX] web: tab selects first many2one entry without triggering spurious create Suppose you select a customer for a sale order. You type the beginning of his name "think", and a name_search is triggered which finds matching results, with first result "Think Big Systems". There are three ways to select it: click, enter or tab. Now there can be a warning set on this customer ("Bad client, only accept cash", or "good client, offer discount"). In that case, clicking on tab would trigger the onchange displaying the warning, but it would also set floating to true, which means a dialog to create client "think" would appear. This happens if the onchange is delayed, and thus the call to reset the floating state is triggered only after the focusout completed, instead of before. Coauthored with @aab-odoo opw 1866619 opw 1874475 --- addons/web/static/src/js/fields/relational_fields.js | 5 +++-- 1 file changed, 3 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 3aaca13b44c..07e31443ffa 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -578,10 +578,11 @@ var FieldMany2One = AbstractField.extend({ * @param {OdooEvent} ev */ _onInputKeyup: function (ev) { - if (ev.which === $.ui.keyCode.ENTER) { - // If we pressed enter, we want to prevent _onInputFocusout from + if (ev.which === $.ui.keyCode.ENTER || ev.which === $.ui.keyCode.TAB) { + // If we pressed enter or tab, we want to prevent _onInputFocusout from // executing since it would open a M2O dialog to request // confirmation that the many2one is not properly set. + // It's a case that is already handled by the autocomplete lib. return; } this.isDirty = true; -- cgit v1.2.3