[FIX] hr_holidays_attendance: remove has_valid_allocation from search_count

In hr_holidays_attendance, the model that inherits from res.users adds a request_overtime field.
This field is used to allow the user to request overtime based on the total overtime.
The domain for the time off type includes has_valid_allocation. If the user doesn't have any allocation,
he won't be able to deduct extra hours

task-2701128

closes odoo/odoo#87845

X-original-commit: b6d186d7b46df1e0f4e0af3eb7c8e7b07909a040
Related: odoo/enterprise#25843
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Philippe Wauthy
2022-04-04 09:24:59 +02:00
parent 7e48e1398c
commit 6abce995d5
2 changed files with 3 additions and 4 deletions
@@ -256,13 +256,14 @@ class HolidaysAllocation(models.Model):
@api.depends('holiday_type')
def _compute_from_holiday_type(self):
default_employee_ids = self.env['hr.employee'].browse(self.env.context.get('default_employee_id')) or self.env.user.employee_id
for allocation in self:
if allocation.holiday_type == 'employee':
if not allocation.employee_ids:
allocation.employee_ids = self.env.user.employee_id
allocation.mode_company_id = False
allocation.category_id = False
if allocation.holiday_type == 'company':
elif allocation.holiday_type == 'company':
allocation.employee_ids = False
if not allocation.mode_company_id:
allocation.mode_company_id = self.env.company
@@ -275,8 +276,7 @@ class HolidaysAllocation(models.Model):
allocation.employee_ids = False
allocation.mode_company_id = False
else:
employee_ids = self.env.context.get('default_employee_id', self.env.user.employee_id)
allocation.employee_ids = [employee_ids] if isinstance(employee_ids, int) else employee_ids
allocation.employee_ids = default_employee_ids
@api.depends('holiday_type', 'employee_id')
def _compute_department_id(self):
@@ -18,7 +18,6 @@ class ResUsers(models.Model):
def _compute_request_overtime(self):
is_holiday_user = self.env.user.has_group('hr_holidays.group_hr_holidays_user')
time_off_types = self.env['hr.leave.type'].search_count([
('has_valid_allocation', '=', True),
('requires_allocation', '=', 'yes'),
('employee_requests', '=', 'yes'),
('overtime_deductible', '=', True)