oca-hr/odoo-bringout-oca-hr-holidays-hr_holidays_public/hr_holidays_public/models/resource_calendar.py
Ernad Husremovic dfcda4100c Move all OCA HR modules from oca-technical to dedicated oca-hr submodule
Reorganized 67 HR-related modules for better structure:
- Moved all odoo-bringout-oca-hr-* packages from packages/oca-technical/
- Now organized in dedicated packages/oca-hr/ submodule
- Includes attendance, expense, holiday, employee, and contract modules
- Maintains all module functionality while improving project organization

This creates a cleaner separation between general technical modules
and HR-specific functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 17:11:28 +02:00

46 lines
1.6 KiB
Python

# Copyright 2017-2018 Tecnativa - Pedro M. Baeza
# Copyright 2018 Brainbean Apps
# Copyright 2020 InitOS Gmbh
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
from odoo.addons.resource.models.resource import Intervals
class ResourceCalendar(models.Model):
_inherit = "resource.calendar"
def _attendance_intervals_batch_exclude_public_holidays(
self, start_dt, end_dt, intervals, resources, tz
):
list_by_dates = (
self.env["hr.holidays.public"]
.get_holidays_list(
start_dt=start_dt.date(),
end_dt=end_dt.date(),
employee_id=self.env.context.get("employee_id", False),
)
.mapped("date")
)
for resource in resources:
interval_resource = intervals[resource.id]
attendances = []
for attendance in interval_resource._items:
if attendance[0].date() not in list_by_dates:
attendances.append(attendance)
intervals[resource.id] = Intervals(attendances)
return intervals
def _attendance_intervals_batch(
self, start_dt, end_dt, resources=None, domain=None, tz=None
):
res = super()._attendance_intervals_batch(
start_dt=start_dt, end_dt=end_dt, resources=resources, domain=domain, tz=tz
)
if self.env.context.get("exclude_public_holidays") and resources:
return self._attendance_intervals_batch_exclude_public_holidays(
start_dt, end_dt, res, resources, tz
)
return res