Skip to content

Commit

Permalink
Merge PR #157 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Dec 19, 2024
2 parents ee03b7e + 4bcdebf commit 4680076
Show file tree
Hide file tree
Showing 2 changed files with 44 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
@@ -1,5 +1,6 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import hr_employee
from . import hr_leave
from . import hr_leave_type
from . import hr_holidays_public
Expand Down
43 changes: 43 additions & 0 deletions hr_holidays_public/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2024 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from datetime import datetime

from odoo import api, models


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

def _get_public_holiday_lines(self, date_start, date_end):
"""Just get the employees holidays"""
domain = self.env["hr.leave"]._get_domain_from_get_unusual_days(
date_from=date_start, date_to=date_end
)
return self.env["hr.holidays.public.line"].search(domain)

@api.model
def get_public_holidays_data(self, date_start, date_end):
# Include public holidays in the calendar summary
res = super().get_public_holidays_data(date_start, date_end)
self = self._get_contextual_employee()
public_holidays = self._get_public_holiday_lines(date_start, date_end).sorted(
"date"
)
res += list(
map(
lambda bh: {
"id": -bh.id,
"colorIndex": 0,
"end": (datetime.combine(bh.date, datetime.max.time())).isoformat(),
"endType": "datetime",
"isAllDay": True,
"start": (
datetime.combine(bh.date, datetime.min.time())
).isoformat(),
"startType": "datetime",
"title": bh.name,
},
public_holidays,
)
)
return sorted(res, key=lambda x: x["start"])

0 comments on commit 4680076

Please sign in to comment.