I have this function I want to : if the current user is the leaves manager ( that I make it from sittings by making this user is leaves manager and in employees is officer) : make this check box True
but even I logged in by leaves manager the check box not checked yet
state = fields.Selection([
('draft', 'To Submit'),
('cancel', 'Cancelled'),
('confirm', 'To Approve'),
('manager', 'Manager Approve'),
('hr_approve','HR Approve'),
('refuse', 'Refused'),
('validate1', 'Second Approval'),
('validate', 'Approved')
], string='Status', readonly=True, track_visibility='onchange', copy=False, default='confirm',
help="The status is set to 'To Submit', when a holiday request is created." +
"\nThe status is 'To Approve', when holiday request is confirmed by user." +
"\nThe status is 'Refused', when holiday request is refused by manager." +
"\nThe status is 'Approved', when holiday request is approved by manager.")
@api.one
@api.depends('state')
def _compute_can_hr_approved(self):
current_user_id = self.env.uid
is_hr=self.env['res.users'].has_group('hr_holidays.group_hr_holidays_manager')
if self.state == 'manager' and current_user_id == is_hr:
self.can_hr_approved = True
else:
self.can_hr_approved = False
self.is_hr=is_hr
is_hr = fields.Many2one('res.users', 'HR', store=True)
can_hr_approved = fields.Boolean(string='Can HR approved', compute='_compute_can_hr_approved')
How to check login user group in odoo: https://goo.gl/Ts3qqK