[FIX]l10n_fr_hr_holidays:fix bug in part-time employee duleaves duration calculation

This commit is contained in:
2026-06-25 18:55:22 +02:00
parent 2f73c1b3a7
commit ecba73e832
5 changed files with 352 additions and 26 deletions

View File

@@ -1,8 +1,11 @@
# -*- coding:utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from collections import defaultdict
from datetime import datetime, time
from odoo import models
class ResourceCalendar(models.Model):
_inherit = 'resource.calendar'
@@ -24,3 +27,16 @@ class ResourceCalendar(models.Model):
for attendance in self.attendance_ids:
working_days[attendance.week_type][attendance.dayofweek] = True
return working_days
def _get_working_dates(self, from_date, to_date, domain=None):
"""Return a set of dates where the company actually works between
from_date and to_date (inclusive), excluding public holidays
and other global leaves registered on the calendar.
"""
self.ensure_one()
from pytz import timezone
tz = timezone(self.tz or 'UTC')
from_dt = tz.localize(datetime.combine(from_date, time.min))
to_dt = tz.localize(datetime.combine(to_date, time(23, 59, 59)))
intervals = self._work_intervals_batch(from_dt, to_dt, domain=domain)[False]
return {start.astimezone(tz).date() for start, stop, meta in intervals}