diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index bdce2f9de44..7151517512a 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -16,7 +16,7 @@ from werkzeug import url_encode from dateutil.relativedelta import relativedelta from openerp.exceptions import UserError, AccessError -from openerp import tools +from openerp import tools, SUPERUSER_ID from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -592,7 +592,8 @@ class hr_employee(osv.Model): def _get_leave_status(self, cr, uid, ids, name, args, context=None): holidays_obj = self.pool.get('hr.holidays') - holidays_id = holidays_obj.search(cr, uid, + #Used SUPERUSER_ID to forcefully get status of other user's leave, to bypass record rule + holidays_id = holidays_obj.search(cr, SUPERUSER_ID, [('employee_id', 'in', ids), ('date_from','<=',time.strftime('%Y-%m-%d %H:%M:%S')), ('date_to','>=',time.strftime('%Y-%m-%d %H:%M:%S')),('type','=','remove'),('state','not in',('cancel','refuse'))], context=context) @@ -604,7 +605,7 @@ class hr_employee(osv.Model): 'leave_date_from':False, 'leave_date_to':False, } - for holiday in self.pool.get('hr.holidays').browse(cr, uid, holidays_id, context=context): + for holiday in self.pool.get('hr.holidays').browse(cr, SUPERUSER_ID, holidays_id, context=context): result[holiday.employee_id.id]['leave_date_from'] = holiday.date_from result[holiday.employee_id.id]['leave_date_to'] = holiday.date_to result[holiday.employee_id.id]['current_leave_state'] = holiday.state diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index 14be0557085..c53f46051ec 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -254,7 +254,7 @@ - + diff --git a/addons/hr_holidays/security/ir_rule.xml b/addons/hr_holidays/security/ir_rule.xml index 64dad315628..c702617382a 100644 --- a/addons/hr_holidays/security/ir_rule.xml +++ b/addons/hr_holidays/security/ir_rule.xml @@ -4,7 +4,7 @@ Employee Holidays - ['|', ('employee_id.user_id','=',user.id), ('state', '=', 'validate')] + [('employee_id.user_id','=',user.id)]