summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
diff options
context:
space:
mode:
authorlen-odoo <len@odoo.com>2018-08-03 16:09:08 +0200
committerlen-odoo <35492570+len-odoo@users.noreply.github.com>2018-09-03 12:09:56 +0200
commitb95b4035e4d05b1ac6fb0b1d9b0c3567b07344d2 (patch)
treeae5be7a7650427c0bef54d839b07db18354dd284 /addons/web/static/src/js/fields/relational_fields.js
parent122f06b86e0b9ea2121308caf4c580f7f5364ced (diff)
[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
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js5
1 files changed, 3 insertions, 2 deletions
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;