summaryrefslogtreecommitdiff
path: root/addons/base/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/base/static/src/js')
-rw-r--r--addons/base/static/src/js/form.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js
index 2624759dece..7517ec23e01 100644
--- a/addons/base/static/src/js/form.js
+++ b/addons/base/static/src/js/form.js
@@ -1121,8 +1121,28 @@ openerp.base.form.FieldSelection = openerp.base.form.Field.extend({
});
},
start: function() {
+ // Flag indicating whether we're in an event chain containing a change
+ // event on the select, in order to know what to do on keyup[RETURN]:
+ // * If the user presses [RETURN] as part of changing the value of a
+ // selection, we should just let the value change and not let the
+ // event broadcast further (e.g. to validating the current state of
+ // the form in editable list view, which would lead to saving the
+ // current row or switching to the next one)
+ // * If the user presses [RETURN] with a select closed (side-effect:
+ // also if the user opened the select and pressed [RETURN] without
+ // changing the selected value), takes the action as validating the
+ // row
+ var ischanging = false;
this._super.apply(this, arguments);
- this.$element.find('select').change(this.on_ui_change);
+ this.$element.find('select')
+ .change(this.on_ui_change)
+ .change(function () { ischanging = true; })
+ .click(function () { ischanging = false; })
+ .keyup(function (e) {
+ if (e.which !== 13 || !ischanging) { return; }
+ e.stopPropagation();
+ ischanging = false;
+ });
},
set_value: function(value) {
value = value === null ? false : value;