From 4a91b626f9eeeb978f85dac996ae64ad8f8b044a Mon Sep 17 00:00:00 2001 From: Philippe Wauthy Date: Wed, 9 Feb 2022 15:41:20 +0000 Subject: [PATCH] [FIX] hr_holidays: fix default duration when creating a new time off from dashboard In the dashboard of Time Off, when clicking on New Time Off, there is a difference of one day between the start and end date and the duration of the time off shows one day. By default, when clicking on the New Time Off button, the start and end date should be the same with a duration of one day. task-2760487 closes odoo/odoo#87864 X-original-commit: dbc16eac2448df63de6cbdaea81e057cd4d78e8a Signed-off-by: Kevin Baptiste --- .../time_off_calendar_controller.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/hr_holidays/static/src/js/time_off_calendar/time_off_calendar_controller.js b/addons/hr_holidays/static/src/js/time_off_calendar/time_off_calendar_controller.js index 7e3da3e3c9e..a35b5120139 100644 --- a/addons/hr_holidays/static/src/js/time_off_calendar/time_off_calendar_controller.js +++ b/addons/hr_holidays/static/src/js/time_off_calendar/time_off_calendar_controller.js @@ -183,9 +183,23 @@ export const TimeOffCalendarController = CalendarController.extend({ }, _getTimeOffContext() { + let date_from = moment().set({ + 'hour': 0, + 'minute': 0, + 'second': 0 + }); + date_from.subtract(this.getSession().getTZOffset(date_from), 'minutes'); + date_from = date_from.locale('en').format('YYYY-MM-DD HH:mm:ss'); + let date_to = moment().set({ + 'hour': 23, + 'minute': 59, + 'second': 59 + }); + date_to.subtract(this.getSession().getTZOffset(date_to), 'minutes'); + date_to = date_to.locale('en').format('YYYY-MM-DD HH:mm:ss'); return { - 'default_date_from': moment().locale('en').format('YYYY-MM-DD'), - 'default_date_to': moment().add(1, 'days').locale('en').format('YYYY-MM-DD'), + 'default_date_from': date_from, + 'default_date_to': date_to, 'lang': this.context.lang, 'form_view_ref': 'hr_holidays.hr_leave_view_form_dashboard_new_time_off' };