Skip to content

Commit

Permalink
fixup! fixup! [ADD] hr_attendance_break
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Nov 13, 2023
1 parent a52ffd9 commit 4a736ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hr_attendance_break/models/hr_attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def add_break(attendance, begin, end):
for this in self:
for _break in this.break_ids:
if not _break.end:
_break.end = _break.begin
_break.end = _break.begin + timedelta(seconds=1)
break_hours -= add_break(
this, _break.end, _break.end + timedelta(hours=break_hours)
)
Expand Down
4 changes: 4 additions & 0 deletions hr_attendance_break/tests/test_hr_attendance_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


import datetime
import time
from unittest.mock import patch

from odoo import exceptions
Expand Down Expand Up @@ -105,6 +106,9 @@ def test_manual_break(self):
self.employee.attendance_manual_break(None)
self.assertTrue(attendance.break_ids)
self.assertEqual(self.employee.hr_presence_state, "absent")
# begin is datetime.now(), but below the code will set
# end to datetime.now() which will fail the constraint begin<end
time.sleep(1)
self.employee.attendance_manual_break(None)
self.assertTrue(attendance.break_ids.end)
self.assertEqual(self.employee.hr_presence_state, "present")
Expand Down

0 comments on commit 4a736ee

Please sign in to comment.