diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 925490b7459..e7feedf26a5 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -118,26 +118,26 @@ openerp.web.parse_value = function (value, descriptor, value_if_empty) { var tmp = Date.parseExact(value, _.sprintf("%s %s", Date.CultureInfo.formatPatterns.shortDate, Date.CultureInfo.formatPatterns.longTime)); if (tmp !== null) - return tmp; + return openerp.web.datetime_to_str(tmp); tmp = Date.parse(value); if (tmp !== null) - return tmp; + return openerp.web.datetime_to_str(tmp); throw value + " is not a valid datetime"; case 'date': var tmp = Date.parseExact(value, Date.CultureInfo.formatPatterns.shortDate); if (tmp !== null) - return tmp; + return openerp.web.date_to_str(tmp); tmp = Date.parse(value); if (tmp !== null) - return tmp; + return openerp.web.date_to_str(tmp); throw value + " is not a valid date"; case 'time': var tmp = Date.parseExact(value, Date.CultureInfo.formatPatterns.longTime); if (tmp !== null) - return tmp; + return openerp.web.time_to_str(tmp); tmp = Date.parse(value); if (tmp !== null) - return tmp; + return openerp.web.time_to_str(tmp); throw value + " is not a valid time"; } return value; diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 6d224a46109..fea6ba21e01 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1146,6 +1146,7 @@ openerp.web.DateTimeWidget = openerp.web.Widget.extend({ self.$element.find('.oe_datepicker').hide(); }); this.set_readonly(false); + this.value = false; }, picker: function() { return $.fn[this.jqueryui_object].apply(this.$element.find('.oe_datepicker_container'), arguments); @@ -1155,12 +1156,11 @@ openerp.web.DateTimeWidget = openerp.web.Widget.extend({ this.$element.find('input').val(date ? this.format_client(date) : '').change(); }, set_value: function(value) { - value = this.parse(value); this.value = value; this.$element.find('input').val(value ? this.format_client(value) : ''); }, get_value: function() { - return this.format(this.value); + return this.value; }, set_value_from_ui: function() { var value = this.$element.find('input').val() || false; @@ -1187,13 +1187,9 @@ openerp.web.DateTimeWidget = openerp.web.Widget.extend({ focus: function() { this.$element.find('input').focus(); }, - parse: openerp.web.auto_str_to_date, parse_client: function(v) { return openerp.web.parse_value(v, {"widget": this.type_of_date}); }, - format: function(val) { - return openerp.web.auto_date_to_str(val, this.type_of_date); - }, format_client: function(v) { return openerp.web.format_value(v, {"widget": this.type_of_date}); },