diff --git a/repos.yml b/repos.yml index 28139c8..7298b92 100644 --- a/repos.yml +++ b/repos.yml @@ -5,6 +5,8 @@ hr-attendance: - oca 15.0 # https://github.com/OCA/hr-attendance/pull/140 - oca refs/pull/140/head + # https://github.com/OCA/hr-attendance/pull/142 + - oca refs/pull/142/head hr-holidays: remotes: oca: https://github.com/OCA/hr-holidays.git diff --git a/verdigado_attendance/__manifest__.py b/verdigado_attendance/__manifest__.py index b877059..0da34ac 100644 --- a/verdigado_attendance/__manifest__.py +++ b/verdigado_attendance/__manifest__.py @@ -11,6 +11,9 @@ "installable": True, "depends": [ "hr_attendance", + "hr_attendance_autoclose", + "hr_attendance_break", + "hr_attendance_break_autoclose", "hr_holidays_attendance", "l10n_de_holidays", "hr_holidays_public_overtime", diff --git a/verdigado_attendance/models/__init__.py b/verdigado_attendance/models/__init__.py index 7b3f71b..46d8b1a 100644 --- a/verdigado_attendance/models/__init__.py +++ b/verdigado_attendance/models/__init__.py @@ -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 diff --git a/verdigado_attendance/models/hr_attendance.py b/verdigado_attendance/models/hr_attendance.py index 4ffb1ff..3b6c28b 100644 --- a/verdigado_attendance/models/hr_attendance.py +++ b/verdigado_attendance/models/hr_attendance.py @@ -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() diff --git a/verdigado_attendance/models/hr_attendance_break.py b/verdigado_attendance/models/hr_attendance_break.py new file mode 100644 index 0000000..d45dc3f --- /dev/null +++ b/verdigado_attendance/models/hr_attendance_break.py @@ -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() diff --git a/verdigado_attendance/models/hr_attendance_report.py b/verdigado_attendance/models/hr_attendance_report.py index ab0c599..3363ede 100644 --- a/verdigado_attendance/models/hr_attendance_report.py +++ b/verdigado_attendance/models/hr_attendance_report.py @@ -11,7 +11,10 @@ class HrAttendanceReport(models.Model): def _join(self): """Add overtime adjustments""" return super()._join() + " UNION %s %s %s" % ( - self._select().replace("hra.worked_hours", "0"), + self._select() + .replace("hra.worked_hours", "0") + .replace("break_hours", "0") + .replace("ot.duration", "0"), self._from(), super()._join().replace("ot.adjustment = FALSE", "ot.adjustment = TRUE"), ) diff --git a/verdigado_attendance/tests/__init__.py b/verdigado_attendance/tests/__init__.py index 368d2aa..262a322 100644 --- a/verdigado_attendance/tests/__init__.py +++ b/verdigado_attendance/tests/__init__.py @@ -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