Skip to content

Commit

Permalink
fixup! [ADD] hr_attendance_break
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Sep 25, 2023
1 parent f3b8120 commit e1b0d73
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
1 change: 1 addition & 0 deletions hr_attendance_break/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"views/hr_attendance.xml",
"views/hr_attendance_break.xml",
"views/hr_attendance_break_threshold.xml",
"views/hr_attendance_reason.xml",
"views/hr_attendance_report.xml",
"views/res_config_settings.xml",
],
Expand Down
1 change: 1 addition & 0 deletions hr_attendance_break/data/hr_attendance_reason.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<field name="name">Imposed break</field>
<field name="action_type">break</field>
<field name="show_on_attendance_screen" eval="False" />
<field name="bypass_minimum_break" eval="True" />
</record>
</data>
14 changes: 5 additions & 9 deletions hr_attendance_break/models/hr_attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ def _compute_break_hours(self):
"""Compute break hours"""
for this in self:
this.break_hours = sum(
filter(
lambda x: x
>= this.employee_id.company_id.hr_attendance_break_min_break,
(
(_break.end - _break.begin).total_seconds() / 3600
for _break in this.break_ids
if _break.begin and _break.end
),
),
this.break_ids.filtered(
lambda x: x.reason_id.bypass_minimum_break
or x.break_hours
>= this.employee_id.company_id.hr_attendance_break_min_break
).mapped("break_hours")
)

@api.depends("break_hours")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class HrAttendanceBreakThreshold(models.Model):
_name = "hr.attendance.break.threshold"
_description = "Minimum break times"
_rec_name = "company_id"
_order = "min_hours desc"

Expand Down
4 changes: 4 additions & 0 deletions hr_attendance_break/models/hr_attendance_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ class HrAttendanceReason(models.Model):
_inherit = "hr.attendance.reason"

action_type = fields.Selection(selection_add=[("break", "Break")])
bypass_minimum_break = fields.Boolean(
help="Check this to have breaks of this type always be counted, independent "
"of minimum break settings"
)
2 changes: 1 addition & 1 deletion hr_attendance_break/views/hr_attendance_break.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<tree editable="bottom">
<field name="begin" />
<field name="end" />
<field name="reason_id" />
<field name="reason_id" domain="[('action_type', '=', 'break')]" />
</tree>
</field>
</record>
Expand Down
17 changes: 17 additions & 0 deletions hr_attendance_break/views/hr_attendance_reason.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data>
<record id="hr_attendance_reason_view_form" model="ir.ui.view">
<field name="model">hr.attendance.reason</field>
<field
name="inherit_id"
ref="hr_attendance_reason.hr_attendance_reason_view_form"
/>
<field name="arch" type="xml">
<field name="show_on_attendance_screen" position="after">
<field name="bypass_minimum_break" />
</field>
</field>
</record>
</data>

0 comments on commit e1b0d73

Please sign in to comment.