[FIX] hr_holidays: fix multi day leaves not being rendered

After https://github.com/odoo/odoo/pull/109736, we started rendering all day
events in the all day slot. However, some calendar views don't have an all day
slot, so these events weren't being shown. Therefore, this commit adds an all
day slot to the hr_holidays module to show multiple day events. Therefore, we
add a new last_several_days computed field in hr leave.

task-3566710

closes odoo/odoo#150980

X-original-commit: cdd8b2fb6b5b3c6a7b1d163368eef791d3d14b3a
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Leonardo Pavan Rocha
2024-01-25 11:50:10 +00:00
committed by Yannick Tivisse
parent bb495ef55e
commit c73aca2e7a
3 changed files with 22 additions and 12 deletions
+6
View File
@@ -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):
@@ -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;
}
+6 -3
View File
@@ -413,7 +413,8 @@
show_unusual_days="True"
color="color"
hide_time="True"
mode="year">
mode="year"
all_day="last_several_days">
<field name="display_name"/>
<field name="holiday_status_id" filters="1" invisible="1" color="color"/>
<field name="state" invisible="1"/>
@@ -438,7 +439,8 @@
quick_create="0"
show_unusual_days="True"
color="color"
hide_time="True">
hide_time="True"
all_day="last_several_days">
<field name="display_name"/>
<field name="holiday_status_id" filters="1" invisible="1" color="color"/>
<field name="state" invisible="1"/>
@@ -494,7 +496,8 @@
mode="month"
show_unusual_days="True"
quick_create="0"
color="color">
color="color"
all_day="last_several_days">
<field name="display_name"/>
<field name="holiday_status_id" color="color" filters="1" invisible="1"/>
<field name="employee_id" filters="1" invisible="1"/>