From ac85176ce81427ba6f55b59e28c1ff6e7e080c32 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 12 Sep 2019 08:05:59 +0000 Subject: [FIX] web: date(time) fields: trigger fieldChanged once Before this rev., the 'fieldChanged' event was triggered each time the user selected a value (a day, an hour, a minute or a second) in the datepicker. This means that if there was an onchange on the field, a lot of RPCs could have been done when a user set a datetime. In addition, in a list view with multi edition, the user was asked to save the changes at each step of the datetime selection, making the feature unusable. Task 2068280 --- addons/web/static/src/js/widgets/date_picker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/widgets') diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js index fd7e9eaf801..8eafd93ef93 100644 --- a/addons/web/static/src/js/widgets/date_picker.js +++ b/addons/web/static/src/js/widgets/date_picker.js @@ -12,7 +12,6 @@ var DateWidget = Widget.extend({ template: "web.datepicker", type_of_date: "date", events: { - 'change.datetimepicker': 'changeDatetime', 'error.datetimepicker': 'errorDatetime', 'change .o_datepicker_input': 'changeDatetime', 'click input': '_onInputClicked', @@ -248,6 +247,7 @@ var DateWidget = Widget.extend({ */ _onDateTimePickerHide: function () { this.__isOpen = false; + this.changeDatetime(); }, /** * Reacts to the datetimepicker being shown -- cgit v1.2.3 From f629cd9672cd22ef0e11ac839c1b500d62ab4e76 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Wed, 18 Sep 2019 15:27:06 +0000 Subject: [FIX] web: write date without separator Since fbbfa6d it's not longer possible to write a date without separator (e.g., 0102 for 01/02/2019; 121298 for 12/12/1998; 02042018 for 02/04/2018), or a date without year (e.g., 01/02 for 01/02/2019) in the datepicker widget. In this commit we have decided to be as permissive as tempus dominus that call moment.js with strict false. This allows moment.js to deduct a date from a string in a more versatile way. This also allows a more versatile autocomplete in the search views. opw-2070464 opw-2070931 closes odoo/odoo#37095 Forward-port-of: odoo/odoo#36821 Signed-off-by: Lucas Perais (lpe) --- addons/web/static/src/js/widgets/date_picker.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'addons/web/static/src/js/widgets') diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js index 8eafd93ef93..6b995afde12 100644 --- a/addons/web/static/src/js/widgets/date_picker.js +++ b/addons/web/static/src/js/widgets/date_picker.js @@ -88,6 +88,13 @@ var DateWidget = Widget.extend({ * set datetime value */ changeDatetime: function () { + if (this.__libInput > 0) { + if (this.options.warn_future) { + this._warnFuture(this.getValue()); + } + this.trigger("datetime_changed"); + return; + } var oldValue = this.getValue(); if (this.isValid()) { this._setValueFromUi(); -- cgit v1.2.3