From b4efb4eeb3e0e7b27a113ad914d5a18e50f8718d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 6 Jul 2015 16:04:49 +0200 Subject: [PATCH] [FIX] web: on calendar with date and time, focus in the field only when hidden The behavior of the datetime widget was to focus in the field every time a date is chosen. This causes an issue if the datetime widget is called from an editable list. Indeed, the list editable will consider that the value has been set, and therefore the value will not be changed anymore if the user choses another date. The new behavior is to put the focus only when the date picker is hidden, therefore the editable list will consider the value set only when the selection is done. opw-644062 Fixes #7463 --- addons/web/static/src/js/view_form.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 52ad15f843e..c285639573a 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2689,7 +2689,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ }); this.picker({ - onClose: this.on_picker_select, + onClose: this.on_picker_close, onSelect: this.on_picker_select, changeMonth: true, changeYear: true, @@ -2718,12 +2718,15 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ picker: function() { return $.fn[this.jqueryui_object].apply(this.$input_picker, arguments); }, + on_picker_close: function (text, instance_) { + this.on_picker_select(text, instance_); + this.$input.focus(); + }, on_picker_select: function(text, instance_) { var date = this.picker('getDate'); this.$input .val(date ? this.format_client(date) : '') - .change() - .focus(); + .change(); }, set_value: function(value_) { this.set({'value': value_});