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_icon
| Inputs | Method | Outputs |
|---|---|---|
|
"""
This method compute the state defining the display icon in the kanban view.
It can be overriden to add other possibilities, like time off or attendances recordings.
"""
- working_now_list = self.filtered(lambda e: e.hr_presence_state == 'present')._get_employee_working_now()
for employee in self:
- show_icon = True
- if employee.hr_presence_state == 'present':
- if employee.id in working_now_list:
- icon = 'presence_present'
- else:
- icon = 'presence_absent_active'
- elif employee.hr_presence_state == 'absent':
- # employee is not in the working_now_list and he has a user_id
- icon = 'presence_absent'
- else:
- # without attendance, default employee state is 'to_define' without confirmed presence/absence
- # we need to check why they are not there
- # Display an orange icon on internal users.
- icon = 'presence_to_define'
- if not employee.user_id:
- # We don't want non-user employee to have icon.
- show_icon = False
- employee.hr_icon_display = icon
- employee.show_hr_icon_display = show_icon
+ employee.hr_icon_display = 'presence_' + employee.hr_presence_state
+ employee.show_hr_icon_display = bool(employee.user_id)
|
|
