Skip to content

Commit

Permalink
[IMP] cut off seconds for attendances and breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Sep 25, 2023
1 parent f904cd7 commit 13d4fb4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions verdigado_attendance/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import hr_attendance
from . import hr_attendance_break
from . import hr_attendance_report
from . import hr_leave_type
9 changes: 5 additions & 4 deletions verdigado_attendance/models/hr_attendance.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

#
# dummy model to allow verdigado_hr_attendance_rule_attendance_manager rule
#

from odoo import models

from .hr_attendance_break import DatetimeWithoutSeconds


class HrAttendance(models.Model):
_inherit = "hr.attendance"

check_in = DatetimeWithoutSeconds()
check_out = DatetimeWithoutSeconds()
20 changes: 20 additions & 0 deletions verdigado_attendance/models/hr_attendance_break.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import fields, models


class DatetimeWithoutSeconds(fields.Datetime):
def convert_to_column(self, value, record, values=None, validate=True):
return super().convert_to_column(
value and self.to_datetime(value).replace(second=0) or value,
record,
values=values,
validate=validate,
)


class HrAttendanceBreak(models.Model):
_inherit = "hr.attendance.break"

begin = DatetimeWithoutSeconds()
end = DatetimeWithoutSeconds()
1 change: 1 addition & 0 deletions verdigado_attendance/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

from . import test_hr_access
from . import test_overtime_calculation
from odoo.addons.hr_attendance_break.tests import test_hr_attendance_break

0 comments on commit 13d4fb4

Please sign in to comment.