From 5bd0318594010aa9987976f616f051b41497f68b Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Wed, 8 Feb 2017 12:53:34 +0100 Subject: [PATCH] [FIX] web: use the default library behaviour The library reset the time set when the date is changed. Then it was not possible to set the time then set the date and expect the widget to close since the time will be reset to the default value. Instead we use the library behaviour and add a 'close' button for the datetime widgets. --- addons/web/static/src/js/widgets/date_picker.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js index 90ec9ed58c6..20171e554a2 100644 --- a/addons/web/static/src/js/widgets/date_picker.js +++ b/addons/web/static/src/js/widgets/date_picker.js @@ -34,6 +34,7 @@ var DateWidget = Widget.extend({ previous: 'fa fa-chevron-left', up: 'fa fa-chevron-up', down: 'fa fa-chevron-down', + close: 'fa fa-times', }, locale : moment.locale(), allowInputToggle: true, @@ -96,16 +97,11 @@ var DateWidget = Widget.extend({ this.picker.date(value); }, - change_datetime: function(e) { + change_datetime: function() { if(this.is_valid()) { this.set_value_from_ui(); this.trigger("datetime_changed"); } - //Close the datetimepicker when a date is selected - //We check only if the date has changed. - if(!e.date.isSame(e.oldDate, 'day')){ - this.picker.hide(); - } }, commit_value: function() { this.change_datetime(); @@ -117,7 +113,13 @@ var DateWidget = Widget.extend({ }); var DateTimeWidget = DateWidget.extend({ - type_of_date: "datetime" + type_of_date: "datetime", + init: function() { + this._super.apply(this, arguments); + this.options = _.defaults(this.options, { + showClose: true, + }); + }, }); return {