From 5ef68945e72322cc0af7ae60a956e59a3d650aee Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 27 Nov 2019 12:50:05 +0000 Subject: [PATCH] [FIX] web: date warning - Set the computer TZ so that it is UTC day + 1. For example, set to 'Australia/Adelaide' and perform the tests after 3:00 pm - Go to Account > Customers > Invoices - Set the Invice Date to today in the TZ You receive the warning 'This date is on the future...' The comparison of a UTC date without time `currentDate` is inconsistent with `moment()`, which is not UTC and has a time set. After playing around with `.utc()` and `startOf('d')` with no luck, we decided to give up the idea of making `getTZOffset()` enter the game and simply compare the string formatted values. opw-2093186 closes odoo/odoo#40984 X-original-commit: f9eec97cb128f71796fca0116841453555ab4684 Signed-off-by: Nicolas Martinelli (nim) --- addons/web/static/src/js/widgets/date_picker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/widgets/date_picker.js b/addons/web/static/src/js/widgets/date_picker.js index bbe40a825ef..9b6a92ea2f4 100644 --- a/addons/web/static/src/js/widgets/date_picker.js +++ b/addons/web/static/src/js/widgets/date_picker.js @@ -207,7 +207,8 @@ var DateWidget = Widget.extend({ this.$warning.attr('title', title); this.$input.after(this.$warning); } - if (currentDate && currentDate.isAfter(moment())) { + // Get rid of time and TZ crap for comparison + if (currentDate && currentDate.format('YYYY-MM-DD') > moment().format('YYYY-MM-DD')) { this.$warning.show(); } else { this.$warning.hide();