From 34bfadb2f2f2f57f4f72515fbc610a521e8f4619 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 24 Jan 2018 04:12:39 -0800 Subject: [PATCH] [FIX] web: suggested date - Set the OS to a GMT- timezone (e.g. 'America/Los Angeles') - Set the format of the date to '%d/%m/%Y' - Go to 'Account > Adviser > Journal Entries' - Type '02-01-2018' The suggested date is 31/01/2018. Setting the moment object as UTC will lead to a conversion of the date to the OS timezone when calling `toDate`, e.g.: Mon Jan 31 2018 16:00:00 GMT-0800 (PST) UTC should only be used in case of datetime, not date. opw-803466 --- addons/web/static/src/js/views/search_inputs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/search_inputs.js b/addons/web/static/src/js/views/search_inputs.js index 6459fba77b8..91d85a1901a 100644 --- a/addons/web/static/src/js/views/search_inputs.js +++ b/addons/web/static/src/js/views/search_inputs.js @@ -354,7 +354,11 @@ var DateField = Field.extend(/** @lends instance.web.search.DateField# */{ } // THIS SHOULD BE FORWARDPORTED UP TO SAAS-15, NOT LATER - var m = moment.utc(v, t === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD'); + if (t === 'datetime') { + var m = moment.utc(v, 'YYYY-MM-DD HH:mm:ss'); + } else { + var m = moment(v, 'YYYY-MM-DD'); + } if (!m.isValid()) { return $.when(null); } var d = m.toDate(); var date_string = formats.format_value(d, this.attrs);