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

Compute Method: _compute_presence_state

View 19.0 View 20.0
Inputs Method Outputs
  • company_id
  • user_id
  • id
  • active
"""
        This method is overritten in several other modules which add additional
        presence criterions. e.g. hr_attendance, hr_holidays
        """
employee_to_check_working = self.filtered(
            lambda e: (e.user_id.sudo().presence_ids.status or "offline") == "offline"
        )
working_now_list = employee_to_check_working._get_employee_working_now()
for employee in self:
            state = 'out_of_working_hour'
            if employee.company_id.sudo().hr_presence_control_login:
                # sudo: res.users - can access presence of accessible user
                presence_status = employee.user_id.sudo().presence_ids.status or "offline"
-                 if presence_status == "online":
+                 if not employee.sudo().is_in_contract:
+                     state = "out_of_working_hour"
+                 elif presence_status == "online":
                    state = 'present'
                elif presence_status == "offline" 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