[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 <kba@odoo.com>
This commit is contained in:
Philippe Wauthy
2022-04-04 12:32:19 +02:00
parent db53118099
commit 4a91b626f9
@@ -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'
};