[IMP] hr_holidays: a time off (duration >= 1day) is displayed as full day
If the duration time off is greater than or equal to 1 day, then it should be displayed as a whole day event. Now it's not a case and can be misleading. Moreover, this change increases querycount for the following reason: When we create allday calendar event, on top of usual queries - "calendar_event"."stop_date" and "calendar_event"."start_date" are read. Note, start_date and end_date are only set for allday events. task-3103848 closes odoo/odoo#113865 Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
This commit is contained in:
committed by
sofiagvaladze
parent
a1bf178ee0
commit
d4f1fb9f10
@@ -1078,9 +1078,11 @@ class HolidaysRequest(models.Model):
|
||||
calendar = holiday.employee_id.resource_calendar_id or company_calendar
|
||||
user = holiday.user_id
|
||||
if holiday.leave_type_request_unit == 'hour':
|
||||
meeting_name = _("%s on Time Off: %.2f hour(s)") % (holiday.employee_id.name or holiday.category_id.name, holiday.number_of_hours_display)
|
||||
meeting_name = _("%s on Time Off : %.2f hour(s)") % (holiday.employee_id.name or holiday.category_id.name, holiday.number_of_hours_display)
|
||||
allday_value = float_compare(holiday.number_of_days, 1.0, 1) >= 0
|
||||
else:
|
||||
meeting_name = _("%s on Time Off: %.2f day(s)") % (holiday.employee_id.name or holiday.category_id.name, holiday.number_of_days)
|
||||
meeting_name = _("%s on Time Off : %.2f day(s)") % (holiday.employee_id.name or holiday.category_id.name, holiday.number_of_days)
|
||||
allday_value = not holiday.request_unit_half
|
||||
meeting_values = {
|
||||
'name': meeting_name,
|
||||
'duration': holiday.number_of_days * (calendar.hours_per_day or HOURS_PER_DAY),
|
||||
@@ -1088,7 +1090,7 @@ class HolidaysRequest(models.Model):
|
||||
'user_id': user.id,
|
||||
'start': holiday.date_from,
|
||||
'stop': holiday.date_to,
|
||||
'allday': False,
|
||||
'allday': allday_value,
|
||||
'privacy': 'confidential',
|
||||
'event_tz': user.tz,
|
||||
'activity_ids': [(5, 0, 0)],
|
||||
|
||||
@@ -32,7 +32,7 @@ class TestWorkEntryHolidaysPerformance(TestWorkEntryHolidaysBase):
|
||||
self.richard_emp.generate_work_entries(date(2018, 1, 1), date(2018, 1, 2))
|
||||
leave = self.create_leave(datetime(2018, 1, 1, 7, 0), datetime(2018, 1, 1, 18, 0))
|
||||
|
||||
with self.assertQueryCount(__system__=95, admin=99):
|
||||
with self.assertQueryCount(__system__=98, admin=102):
|
||||
leave.action_validate()
|
||||
leave.action_refuse()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user