diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py
index 40e0c7de4f2..3cf290f881a 100644
--- a/addons/hr_holidays/models/hr_leave.py
+++ b/addons/hr_holidays/models/hr_leave.py
@@ -176,6 +176,7 @@ class HolidaysRequest(models.Model):
number_of_hours = fields.Float(
'Duration (Hours)', compute='_compute_duration', store=True, tracking=True,
help='Number of hours of the time off request. Used in the calculation.')
+ last_several_days = fields.Boolean("All day", compute="_compute_last_several_days")
number_of_days_display = fields.Float(
'Duration in days', compute='_compute_number_of_days_display',
help='Number of days of the time off request according to your working schedule. Used for interface.')
@@ -582,6 +583,11 @@ class HolidaysRequest(models.Model):
or holiday.department_id.company_id \
or self.env.company
+ @api.depends('number_of_days')
+ def _compute_last_several_days(self):
+ for holiday in self:
+ holiday.last_several_days = holiday.number_of_days > 1
+
@api.depends('tz')
@api.depends_context('uid')
def _compute_tz_mismatch(self):
diff --git a/addons/hr_holidays/static/src/views/calendar/calendar_model.js b/addons/hr_holidays/static/src/views/calendar/calendar_model.js
index ad218d1b7c9..7c899d62be3 100644
--- a/addons/hr_holidays/static/src/views/calendar/calendar_model.js
+++ b/addons/hr_holidays/static/src/views/calendar/calendar_model.js
@@ -26,19 +26,20 @@ export class TimeOffCalendarModel extends CalendarModel {
}
makeContextDefaults(record) {
- const { scale } = this.meta;
const context = super.makeContextDefaults(record);
if (this.employeeId) {
- context['default_employee_id'] = this.employeeId;
+ context["default_employee_id"] = this.employeeId;
}
- if(['day', 'week'].includes(scale)) {
- if ('default_date_from' in context) {
- context['default_date_from'] = serializeDateTime(deserializeDateTime(context['default_date_from']).set({ hours: 7 }));
- }
- if ('default_date_to' in context) {
- context['default_date_to'] = serializeDateTime(deserializeDateTime(context['default_date_from']).set({ hours: 19 }));
- }
+ if ("default_date_from" in context) {
+ context["default_date_from"] = serializeDateTime(
+ deserializeDateTime(context["default_date_from"]).set({ hours: 7 })
+ );
+ }
+ if ("default_date_to" in context) {
+ context["default_date_to"] = serializeDateTime(
+ deserializeDateTime(context["default_date_from"]).set({ hours: 19 })
+ );
}
return context;
}
diff --git a/addons/hr_holidays/views/hr_leave_views.xml b/addons/hr_holidays/views/hr_leave_views.xml
index 211ab46dac0..dc5bde16223 100644
--- a/addons/hr_holidays/views/hr_leave_views.xml
+++ b/addons/hr_holidays/views/hr_leave_views.xml
@@ -413,7 +413,8 @@
show_unusual_days="True"
color="color"
hide_time="True"
- mode="year">
+ mode="year"
+ all_day="last_several_days">
@@ -438,7 +439,8 @@
quick_create="0"
show_unusual_days="True"
color="color"
- hide_time="True">
+ hide_time="True"
+ all_day="last_several_days">
@@ -494,7 +496,8 @@
mode="month"
show_unusual_days="True"
quick_create="0"
- color="color">
+ color="color"
+ all_day="last_several_days">