[FIX] hr, hr_contract: fix employee attendance data fetch
Before this commit, _get_calendar_attendances was calling the calendar method get_work_duration_data without specifying the company in the domain, ending up in wrong data if global leaves that don't concern the employee are concerning the calendar. This commit adds a domain for that method call so that only relevent global leaves are taken into account. closes odoo/odoo#148043
This commit is contained in:
@@ -517,7 +517,12 @@ class HrEmployeePrivate(models.Model):
|
||||
def _get_calendar_attendances(self, date_from, date_to):
|
||||
self.ensure_one()
|
||||
employee_timezone = timezone(self.tz) if self.tz else None
|
||||
return self.resource_calendar_id.with_context(employee_timezone=employee_timezone).get_work_duration_data(date_from, date_to)
|
||||
return self.resource_calendar_id\
|
||||
.with_context(employee_timezone=employee_timezone)\
|
||||
.get_work_duration_data(
|
||||
date_from,
|
||||
date_to,
|
||||
domain=[('company_id', 'in', [False, self.company_id.id])])
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Business Methods
|
||||
|
||||
@@ -146,7 +146,12 @@ class Employee(models.Model):
|
||||
if not valid_contracts:
|
||||
return super()._get_calendar_attendances(date_from, date_to)
|
||||
employee_timezone = timezone(self.tz) if self.tz else None
|
||||
return valid_contracts.resource_calendar_id.with_context(employee_timezone=employee_timezone).get_work_duration_data(date_from, date_to)
|
||||
return valid_contracts.resource_calendar_id\
|
||||
.with_context(employee_timezone=employee_timezone)\
|
||||
.get_work_duration_data(
|
||||
date_from,
|
||||
date_to,
|
||||
domain=[('company_id', 'in', [False, self.company_id.id])])
|
||||
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
|
||||
Reference in New Issue
Block a user