Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions hr_attendance_leave_report/models/hr_attendance_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,18 @@ def _get_leave(self, contract, work_date, vals):
("date_to_without_hour", ">=", work_date),
("state", "=", "validate"),
]
leave = self.env["hr.leave"].search(cond, limit=1)
if leave:
hours = vals.get("hours_to_work")
if leave.holiday_status_id.request_unit != "day":
hours = leave.number_of_hours
vals["leave_type_id"] = leave.holiday_status_id.id
vals["day_type"] = leave.holiday_status_id.name
if leave.holiday_status_id.time_type == "other":
vals["remunerated_hours"] = hours
if leave.holiday_status_id.time_type != "other":
vals["non_remunerated_hours"] = hours
leaves = self.env["hr.leave"].search(cond)
if leaves:
names = []
for leave in leaves:
hours = vals.get("hours_to_work")
if leave.holiday_status_id.request_unit != "day":
hours = leave.number_of_hours
vals["leave_type_id"] = leave.holiday_status_id.id
names.append(leave.holiday_status_id.name)
if leave.holiday_status_id.time_type == "other":
vals["remunerated_hours"] += hours
else:
vals["non_remunerated_hours"] += hours
vals["day_type"] = " + ".join(names)
return vals