From d4f1fb9f10542b0a374f0d7e9cd8066c2d4dd290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lanie=20Peyrat=20=28mepe=29?= Date: Tue, 28 Feb 2023 11:11:47 +0100 Subject: [PATCH] [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) --- addons/hr_holidays/models/hr_leave.py | 8 +++++--- addons/hr_work_entry_holidays/tests/test_performance.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index 0ee0a936b7d..f6cec3e668b 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -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)], diff --git a/addons/hr_work_entry_holidays/tests/test_performance.py b/addons/hr_work_entry_holidays/tests/test_performance.py index c878ef06d2c..d78e98adbbb 100644 --- a/addons/hr_work_entry_holidays/tests/test_performance.py +++ b/addons/hr_work_entry_holidays/tests/test_performance.py @@ -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()