diff options
| author | Kevin Baptiste <kba@odoo.com> | 2020-05-04 14:46:18 +0000 |
|---|---|---|
| committer | Arnaud Joset <arj@odoo.com> | 2020-08-05 12:22:29 +0000 |
| commit | d24de2554e24431f9241c12f7202d4c9960edca0 (patch) | |
| tree | ae83068e24fbcdd467e385c9a087e2a091d50798 /addons/hr_attendance | |
| parent | b6489f2763c3f062ab2e5a96b2c804b445f79809 (diff) | |
[IMP] hr,hr_attendance,hr_contract,hr_holidays,hr_presence: update employees presence icons
Make the employee presence icons more descriptive.
Allow to quickly filter the Presence Reports based on the user status.
closes odoo/odoo#54527
Taskid: 2246447
Related: odoo/upgrade#1488
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/hr_attendance')
| -rw-r--r-- | addons/hr_attendance/models/hr_employee.py | 19 | ||||
| -rw-r--r-- | addons/hr_attendance/static/src/scss/hr_attendance.scss | 4 | ||||
| -rw-r--r-- | addons/hr_attendance/views/hr_employee_view.xml | 4 |
3 files changed, 20 insertions, 7 deletions
diff --git a/addons/hr_attendance/models/hr_employee.py b/addons/hr_attendance/models/hr_employee.py index ce541dd326b..b1901554e44 100644 --- a/addons/hr_attendance/models/hr_employee.py +++ b/addons/hr_attendance/models/hr_employee.py @@ -20,18 +20,22 @@ class HrEmployeeBase(models.AbstractModel): hours_today = fields.Float(compute='_compute_hours_today') hours_last_month_display = fields.Char(compute='_compute_hours_last_month') + @api.depends('user_id.im_status', 'attendance_state') def _compute_presence_state(self): """ Override to include checkin/checkout in the presence state Attendance has the second highest priority after login """ super()._compute_presence_state() - employees = self.filtered(lambda employee: employee.hr_presence_state != 'present') + employees = self.filtered(lambda e: e.hr_presence_state != 'present') + employee_to_check_working = self.filtered(lambda e: e.attendance_state == 'checked_out' + and e.hr_presence_state == 'to_define') + working_now_list = employee_to_check_working._get_employee_working_now() for employee in employees: - if employee.attendance_state == 'checked_out' and employee.hr_presence_state == 'to_define': + if employee.attendance_state == 'checked_out' and employee.hr_presence_state == 'to_define' and \ + employee.id not in working_now_list: employee.hr_presence_state = 'absent' - for employee in employees: - if employee.attendance_state == 'checked_in': + elif employee.attendance_state == 'checked_in': employee.hr_presence_state = 'present' def _compute_hours_last_month(self): @@ -161,3 +165,10 @@ class HrEmployeeBase(models.AbstractModel): if 'pin' in groupby or 'pin' in self.env.context.get('group_by', '') or self.env.context.get('no_group_by'): raise exceptions.UserError(_('Such grouping is not allowed.')) return super(HrEmployeeBase, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy) + + def _compute_presence_icon(self): + res = super()._compute_presence_icon() + # All employee must chek in or check out. Everybody must have an icon + employee_to_define = self.filtered(lambda e: e.hr_icon_display == 'presence_undetermined') + employee_to_define.hr_icon_display = 'presence_to_define' + return res diff --git a/addons/hr_attendance/static/src/scss/hr_attendance.scss b/addons/hr_attendance/static/src/scss/hr_attendance.scss index 193d8b40e35..4bd2b65de71 100644 --- a/addons/hr_attendance/static/src/scss/hr_attendance.scss +++ b/addons/hr_attendance/static/src/scss/hr_attendance.scss @@ -8,8 +8,8 @@ &.oe_hr_attendance_status_green { color: theme-color('success'); } - &.oe_hr_attendance_status_red { - color: theme-color('danger'); + &.oe_hr_attendance_status_orange { + color: theme-color('warning'); } } diff --git a/addons/hr_attendance/views/hr_employee_view.xml b/addons/hr_attendance/views/hr_employee_view.xml index 63c593fc082..8928b07b9b2 100644 --- a/addons/hr_attendance/views/hr_employee_view.xml +++ b/addons/hr_attendance/views/hr_employee_view.xml @@ -132,7 +132,9 @@ <span id="oe_hr_attendance_status" class="fa fa-circle oe_hr_attendance_status_green" role="img" aria-label="Available" title="Available"></span> </div> <div class="float-right" t-if="record.attendance_state.raw_value == 'checked_out'"> - <span id="oe_hr_attendance_status" class="fa fa-circle oe_hr_attendance_status_red" role="img" aria-label="Not available" title="Not available"></span> + <span id="oe_hr_attendance_status" class="fa fa-circle oe_hr_attendance_status_orange" + role="img" aria-label="Not available" title="Not available"> + </span> </div> <strong> <field name="name"/> |
