[IMP]hr_employee_stats_sheet: fix leave hours when several leaves exits for the same days
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hr_employee_stats_sheet",
|
||||
"version": "16.0.3.0.2",
|
||||
"version": "16.0.3.0.3",
|
||||
"description": "Add global sheet for employee stats",
|
||||
"summary": "Add global sheet for employee stats",
|
||||
"author": "Nicolas JEUDY",
|
||||
|
||||
@@ -114,23 +114,23 @@ class HrEmployeeStats(models.Model):
|
||||
recovery = self.env["hr.leave"]
|
||||
total_recovery_hours = 0
|
||||
if self.date and self.employee_id and self._get_holiday_status_id():
|
||||
recovery_id = recovery.search(
|
||||
recovery_ids = recovery.search(
|
||||
[
|
||||
("employee_id", "=", self.employee_id.id),
|
||||
("holiday_status_id", "=", self._get_holiday_status_id()),
|
||||
("request_date_from", "<=", self.date),
|
||||
("request_date_to", ">=", self.date),
|
||||
],
|
||||
limit=1
|
||||
)
|
||||
if recovery_id:
|
||||
if recovery_id.request_unit_hours:
|
||||
recovery_hours = recovery_id.number_of_hours_display
|
||||
total_recovery_hours = min(recovery_hours,self._get_total_planned_hours())
|
||||
elif recovery_id.request_unit_half:
|
||||
total_recovery_hours = self._get_total_planned_hours() / 2
|
||||
else :
|
||||
total_recovery_hours = self._get_total_planned_hours()
|
||||
if recovery_ids:
|
||||
for recovery_id in recovery_ids:
|
||||
if recovery_id.request_unit_hours:
|
||||
recovery_hours = recovery_id.number_of_hours_display
|
||||
total_recovery_hours += min(recovery_hours,self._get_total_planned_hours())
|
||||
elif recovery_id.request_unit_half:
|
||||
total_recovery_hours += self._get_total_planned_hours() / 2
|
||||
else :
|
||||
total_recovery_hours += self._get_total_planned_hours()
|
||||
return total_recovery_hours
|
||||
|
||||
def _get_total_leave_hours(self):
|
||||
@@ -138,23 +138,23 @@ class HrEmployeeStats(models.Model):
|
||||
leave = self.env["hr.leave"]
|
||||
total_leave_hours = 0
|
||||
if self.date and self.employee_id:
|
||||
leave_id = leave.search(
|
||||
leave_ids = leave.search(
|
||||
[
|
||||
("employee_id", "=", self.employee_id.id),
|
||||
("holiday_status_id", "!=", self._get_holiday_status_id()),
|
||||
("request_date_from", "<=", self.date),
|
||||
("request_date_to", ">=", self.date),
|
||||
],
|
||||
limit=1
|
||||
)
|
||||
if leave_id:
|
||||
if leave_id.request_unit_hours:
|
||||
leave_hours = leave_id.number_of_hours_display
|
||||
total_leave_hours = min(leave_hours,self._get_total_planned_hours())
|
||||
elif leave_id.request_unit_half:
|
||||
total_leave_hours = self._get_total_planned_hours() / 2
|
||||
else :
|
||||
total_leave_hours = self._get_total_planned_hours()
|
||||
if leave_ids:
|
||||
for leave_id in leave_ids:
|
||||
if leave_id.request_unit_hours:
|
||||
leave_hours = leave_id.number_of_hours_display
|
||||
total_leave_hours += min(leave_hours,self._get_total_planned_hours())
|
||||
elif leave_id.request_unit_half:
|
||||
total_leave_hours += self._get_total_planned_hours() / 2
|
||||
else :
|
||||
total_leave_hours += self._get_total_planned_hours()
|
||||
return total_leave_hours
|
||||
|
||||
@api.depends("employee_id", "date")
|
||||
|
||||
Reference in New Issue
Block a user