From 5a2e8f6fee3497fe79569154c31d55a411e50523 Mon Sep 17 00:00:00 2001 From: RomainLibert Date: Mon, 9 Sep 2019 09:51:19 +0000 Subject: [PATCH] [FIX] hr_holidays: set correct domain on holiday_status_id --- addons/hr_holidays/models/hr_leave_allocation.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index e01286750fd..49e7faa0f7b 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -35,6 +35,11 @@ class HolidaysAllocation(models.Model): domain = [('valid', '=', True), ('allocation_type', '=', 'fixed_allocation')] return self.env['hr.leave.type'].search(domain, limit=1) + def _holiday_status_id_domain(self): + if self.user_has_groups('hr_holidays.group_hr_holidays_manager'): + return [('valid', '=', True), ('allocation_type', '!=', 'no')] + return [('valid', '=', True), ('allocation_type', '=', 'fixed_allocation')] + name = fields.Char('Description') state = fields.Selection([ ('draft', 'To Submit'), @@ -57,7 +62,7 @@ class HolidaysAllocation(models.Model): holiday_status_id = fields.Many2one( "hr.leave.type", string="Time Off Type", required=True, readonly=True, states={'draft': [('readonly', False)], 'confirm': [('readonly', False)]}, - domain=[('valid', '=', True), ('allocation_type', '!=', 'no')], default=_default_holiday_status_id) + domain=_holiday_status_id_domain, default=_default_holiday_status_id) employee_id = fields.Many2one( 'hr.employee', string='Employee', index=True, readonly=True, ondelete="restrict", states={'draft': [('readonly', False)], 'confirm': [('readonly', False)]}, default=_default_employee, tracking=True)