diff --git a/hr_attendance_break/__manifest__.py b/hr_attendance_break/__manifest__.py
index 1347653a..c22b59cc 100644
--- a/hr_attendance_break/__manifest__.py
+++ b/hr_attendance_break/__manifest__.py
@@ -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",
],
diff --git a/hr_attendance_break/data/hr_attendance_reason.xml b/hr_attendance_break/data/hr_attendance_reason.xml
index 95ad49f6..a851987a 100644
--- a/hr_attendance_break/data/hr_attendance_reason.xml
+++ b/hr_attendance_break/data/hr_attendance_reason.xml
@@ -6,5 +6,6 @@
Imposed break
break
+
diff --git a/hr_attendance_break/models/hr_attendance.py b/hr_attendance_break/models/hr_attendance.py
index 001c190a..18370923 100644
--- a/hr_attendance_break/models/hr_attendance.py
+++ b/hr_attendance_break/models/hr_attendance.py
@@ -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")
diff --git a/hr_attendance_break/models/hr_attendance_break_threshold.py b/hr_attendance_break/models/hr_attendance_break_threshold.py
index 6f408382..3b19a259 100644
--- a/hr_attendance_break/models/hr_attendance_break_threshold.py
+++ b/hr_attendance_break/models/hr_attendance_break_threshold.py
@@ -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"
diff --git a/hr_attendance_break/models/hr_attendance_reason.py b/hr_attendance_break/models/hr_attendance_reason.py
index d76ec22e..2fbfab37 100644
--- a/hr_attendance_break/models/hr_attendance_reason.py
+++ b/hr_attendance_break/models/hr_attendance_reason.py
@@ -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"
+ )
diff --git a/hr_attendance_break/views/hr_attendance_break.xml b/hr_attendance_break/views/hr_attendance_break.xml
index de0c20be..ae041aa9 100644
--- a/hr_attendance_break/views/hr_attendance_break.xml
+++ b/hr_attendance_break/views/hr_attendance_break.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/hr_attendance_break/views/hr_attendance_reason.xml b/hr_attendance_break/views/hr_attendance_reason.xml
new file mode 100644
index 00000000..719eb47b
--- /dev/null
+++ b/hr_attendance_break/views/hr_attendance_reason.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ hr.attendance.reason
+
+
+
+
+
+
+
+