From a029fca2d0def06ea3f67270f0e1d654d49a0c57 Mon Sep 17 00:00:00 2001 From: Priyanka Kakadiya Date: Tue, 6 Oct 2020 09:56:39 +0000 Subject: [FIX] web: send utc date to server from daterange widget When manually updating the time on a daterange widget, the value sent to the server is not converted to UTC and is sent as it appears on the input. currently daterange widget send datetime value as it is, written in input field if manually entered, so if user set 10:00:00 so while sending data it will be send as it is 10:00:00 so when next time record reloaded after save, it will display 15:30:00 if timezone UTC+5:30. Instead, change the string date to moment object with current user timezone. so that datetime send to server is UTC time and when next time it is loaded it adds user timezone difference, so if timezone is UTC+5:30 and user enters 10:00:00 then while sending data to server it sends 04:30:00 and when displayed again after reload it adds +5:30 timezone difference. LINKS PR #50132 Task 2240378 closes odoo/odoo#59208 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/fields/basic_fields.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index efa9f522c98..e194ee6b522 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -638,6 +638,15 @@ var FieldDateRange = InputField.extend({ } this._super.apply(this, arguments); }, + /** + * Return the date written in the input, in UTC. + * + * @private + * @returns {Moment|false} + */ + _getValue: function () { + return field_utils.parse[this.formatType](this.$input.val(), this.field, { timezone: true }); + }, //-------------------------------------------------------------------------- // Private -- cgit v1.2.3