summaryrefslogtreecommitdiff
path: root/addons/hr_holidays/models
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2021-04-08 12:56:13 +0000
committerGoffin Simon <sig@odoo.com>2021-05-04 15:24:08 +0000
commitf964b761eae32016e36dd9d39cc2c35fc2270eba (patch)
tree153fcbad8085d0fb89c7c426a15e1f5fd409662d /addons/hr_holidays/models
parent7afb8e3193615d54f9e1b40a453eaf7f6c456dad (diff)
[WIP] hr_holidays: Leaves for partial time are wrongly counted
Steps to reproduce the bug: - Let's consider an employee E that doesn't work on Monday morning - Create a half day leave request LR for E on a Monday afternoon - Save Bug: The duration of LR was counted as one day instead of 0.5 opw:2491784 closes odoo/odoo#68977 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Diffstat (limited to 'addons/hr_holidays/models')
-rw-r--r--addons/hr_holidays/models/hr_leave.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py
index e3121f4532b..de259666d4f 100644
--- a/addons/hr_holidays/models/hr_leave.py
+++ b/addons/hr_holidays/models/hr_leave.py
@@ -594,7 +594,10 @@ class HolidaysRequest(models.Model):
""" Returns a float equals to the timedelta between two dates given as string."""
if employee_id:
employee = self.env['hr.employee'].browse(employee_id)
- return employee._get_work_days_data_batch(date_from, date_to)[employee.id]
+ result = employee._get_work_days_data_batch(date_from, date_to)[employee.id]
+ if self.request_unit_half:
+ result['days'] = 0.5
+ return result
today_hours = self.env.company.resource_calendar_id.get_work_hours_count(
datetime.combine(date_from.date(), time.min),
@@ -602,8 +605,8 @@ class HolidaysRequest(models.Model):
False)
hours = self.env.company.resource_calendar_id.get_work_hours_count(date_from, date_to)
-
- return {'days': hours / (today_hours or HOURS_PER_DAY), 'hours': hours}
+ days = hours / (today_hours or HOURS_PER_DAY) if not self.request_unit_half else 0.5
+ return {'days': days, 'hours': hours}
def _adjust_date_based_on_tz(self, leave_date, hour):
""" request_date_{from,to} are local to the user's tz but hour_{from,to} are in UTC.