diff options
| author | Khoi Nguyen <bng@odoo.com> | 2017-07-13 17:40:35 +0200 |
|---|---|---|
| committer | Khoi Nguyen <bng@odoo.com> | 2017-07-14 10:35:35 +0200 |
| commit | f2c7e44efe4e2bcdc9c77c66dbd56b8b4cc397b2 (patch) | |
| tree | 8c96109442c3670873be528d051dd446c4c32f18 /addons/web/static/src/js/fields | |
| parent | a562f5ced1c61d2ac3854a17d193beda4d64b5e1 (diff) | |
[FIX] web: no M2ODialog when pressing enter in a many2one
Before this revision, pressing ENTER when inside a many2one field
triggers a 'focus out' event. In particular, if one creates a many2one
record and uses the ENTER key to click "Create and Edit", two dialog
windows appear: one to actually create the associated record, and a
second to alert the user that they are creating an associated record.
The latter appears every time the many2one field loses focus.
This commit changes the 'key up' event for many2one fields to ensure
that the ENTER key does not trigger a 'focus out' event.
Diffstat (limited to 'addons/web/static/src/js/fields')
| -rw-r--r-- | addons/web/static/src/js/fields/relational_fields.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 822955fcf3c..14512c02912 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -485,8 +485,16 @@ var FieldMany2One = AbstractField.extend({ }, /** * @private + * + * @param {OdooEvent} ev */ - _onInputKeyup: function () { + _onInputKeyup: function (ev) { + if (ev.which === $.ui.keyCode.ENTER) { + // If we pressed enter, we want to prevent _onInputFocusout from + // executing since it would open a M2O dialog to request + // confirmation that the many2one is not properly set. + return; + } if (this.$input.val() === "") { this.reinitialize(false); } else if (this._getDisplayName(this.m2o_value) !== this.$input.val()) { |
