Skip to content

Commit

Permalink
[IMP] hr_holidays_public: include public holidays in employee's _get_…
Browse files Browse the repository at this point in the history
…unusual_days
  • Loading branch information
AaronHForgeFlow committed Nov 19, 2024
1 parent 6344279 commit 4cc00b0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions hr_holidays_public/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from . import hr_leave_type
from . import hr_holidays_public
from . import resource_calendar
from . import hr_employee
17 changes: 17 additions & 0 deletions hr_holidays_public/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import fields, models


class HREmployee(models.Model):
_inherit = "hr.employee"

def _get_unusual_days(self, date_from, date_to=None):
res = super()._get_unusual_days(date_from, date_to=date_to)
if not self:
return res
domain = self.env["hr.leave"]._get_domain_from_get_unusual_days(
date_from=date_from, date_to=date_to
)
public_holidays = self.env["hr.holidays.public.line"].search(domain)
for public_holiday in public_holidays:
res[fields.Date.to_string(public_holiday.date)] = True
return res
7 changes: 7 additions & 0 deletions hr_holidays_public/tests/test_holidays_public.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,10 @@ def test_calendar_attendance_interval_exclude_public_holidays(self):
self.assertEqual(
intervals_sl[resource_sl.id]._items, intervals_sk_sl[resource_sl.id]._items
)

def _test_get_unusual_days(self):
# Test for _get_unusual_days
unusual_days = self.employee._get_unusual_days("1994-11-14", "1994-11-14")
self.assertIn("1994-10-14", unusual_days)
self.assertTrue(unusual_days["1994-10-14"])
self.assertNotIn("1994-10-15", unusual_days)

0 comments on commit 4cc00b0

Please sign in to comment.