Skip to content
Snippets Groups Projects
Commit d80a3965 authored by Wolfgang Taferner's avatar Wolfgang Taferner
Browse files

[FIX] hr_*: unusual days + public holidays independent of employee


In case we use multi company and a user does not have an employee
in every company which is quite normal (mostly you are employed with
exactly one company), the calendar is skipping the provision of the
unusual days like public holidays or the working schedule.

To be able to access and see the calendar in such a case we fallback
to the company calendar and fixed a domain for the public holiday
retrieval whereas the public holidays are not assigned to an employee
but the company or the companies chosen to be displayed.

closes odoo/odoo#126289

Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
parent f792637a
No related branches found
No related tags found
No related merge requests found
......@@ -496,12 +496,8 @@ class HrEmployeePrivate(models.Model):
def _get_unusual_days(self, date_from, date_to=None):
# Checking the calendar directly allows to not grey out the leaves taken
# by the employee
# Prevents a traceback when loading calendar views and no employee is linked to the user.
if not self:
return {}
self.ensure_one()
return self.resource_calendar_id._get_unusual_days(
# by the employee or fallback to the company calendar
return (self.resource_calendar_id or self.env.company.resource_calendar_id)._get_unusual_days(
datetime.combine(fields.Date.from_string(date_from), time.min).replace(tzinfo=UTC),
datetime.combine(fields.Date.from_string(date_to), time.max).replace(tzinfo=UTC)
)
......
......@@ -315,7 +315,7 @@ class HrEmployee(models.Model):
def _get_public_holidays(self, date_start, date_end):
domain = [
('resource_id', '=', False),
('company_id', 'in', (self.company_id.id, False)),
('company_id', 'in', self.env.companies.ids),
('date_from', '<=', date_end),
('date_to', '>=', date_start),
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment