From 6abce995d5edce54c52ca4fdb0c7d4bff789cd9f Mon Sep 17 00:00:00 2001 From: Philippe Wauthy Date: Fri, 31 Dec 2021 16:09:21 +0000 Subject: [PATCH] [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 --- addons/hr_holidays/models/hr_leave_allocation.py | 6 +++--- addons/hr_holidays_attendance/models/res_users.py | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index f44d73d6fc0..53b62f2acea 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -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): diff --git a/addons/hr_holidays_attendance/models/res_users.py b/addons/hr_holidays_attendance/models/res_users.py index 6fb8738bb22..0a0f8a15c21 100644 --- a/addons/hr_holidays_attendance/models/res_users.py +++ b/addons/hr_holidays_attendance/models/res_users.py @@ -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)