Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Employees

Entity: hr.employee.base

Compute Method: _compute_presence_state

View 17.0 View 18.0
Inputs Method Outputs
  • user_id
  • user_id.im_status
  • id
  • company_id
  • company_id.hr_presence_control_login
  • active
"""
        This method is overritten in several other modules which add additional
        presence criterions. e.g. hr_attendance, hr_holidays
        """
- check_login = literal_eval(self.env['ir.config_parameter'].sudo().get_param('hr.hr_presence_control_login', 'False'))
- employee_to_check_working = self.filtered(lambda e: e.user_id.im_status == 'offline')
+ employee_to_check_working = self.filtered(lambda e: 'offline' in str(e.user_id.im_status))
working_now_list = employee_to_check_working._get_employee_working_now()
for employee in self:
-             state = 'to_define'
-             if check_login:
-                 if employee.user_id.im_status in ['online', 'leave_online']:
+             state = 'out_of_working_hour'
+             if employee.company_id.hr_presence_control_login:
+                 if employee.user_id._is_user_available():
                    state = 'present'
-                 elif employee.user_id.im_status in ['offline', 'leave_offline'] and employee.id not in working_now_list:
+                 elif 'offline' in str(employee.user_id.im_status) and employee.id in working_now_list:
                    state = 'absent'
+             if not employee.active:
+                 state = 'archive'
            employee.hr_presence_state = state
  • hr_presence_state

Back to entity