Skip to content

Commit

Permalink
[ADD] #80 show adjustment hours on attendance report
Browse files Browse the repository at this point in the history
fixes #80
  • Loading branch information
hbrunn committed Jan 22, 2024
1 parent 9c2f8ee commit 491e167
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions verdigado_attendance/models/hr_attendance_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class HrAttendanceReport(models.Model):
_inherit = "hr.attendance.report"

expected_hours = fields.Float()
adjustment_hours = fields.Float()

def _select(self):
"""Add expected hours"""
Expand All @@ -23,7 +24,7 @@ def _select(self):
JOIN hr_employee employee ON employee.id = hr_attendance.employee_id
WHERE calendar.id = employee.resource_calendar_id))))::date""",
)
+ ", coalesce(ot.expected_hours, 0) expected_hours"
+ ", coalesce(ot.expected_hours, 0) expected_hours, 0 adjustment_hours"
)

def _join(self):
Expand All @@ -32,7 +33,8 @@ def _join(self):
self._select()
.replace("hra.worked_hours", "0")
.replace("break_hours", "0")
.replace("coalesce(ot.expected_hours, 0)", "0"),
.replace("coalesce(ot.expected_hours, 0)", "0")
.replace("0 adjustment_hours", "coalesce(ot.duration, 0)"),
self._from(),
super()._join().replace("ot.adjustment = FALSE", "ot.adjustment = TRUE"),
)
3 changes: 3 additions & 0 deletions verdigado_attendance/views/hr_attendance_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<field name="worked_hours" position="before">
<field name="expected_hours" type="measure" widget="float_time" />
</field>
<field name="overtime_hours" position="before">
<field name="adjustment_hours" type="measure" widget="float_time" />
</field>
</field>
</record>
<record
Expand Down

0 comments on commit 491e167

Please sign in to comment.