[FIX] hr_attendance: compute attendance state as sudo()

Since `last_attendance_id` is stored, `sudo` is needed as employees
doesn't have access to their collegues attendances.
This commit is contained in:
Christophe Simonis
2018-05-15 13:51:02 +02:00
parent 4412cb0bf4
commit 96e5455079
+2 -1
View File
@@ -54,7 +54,8 @@ class HrEmployee(models.Model):
@api.depends('last_attendance_id.check_in', 'last_attendance_id.check_out', 'last_attendance_id')
def _compute_attendance_state(self):
for employee in self:
employee.attendance_state = employee.last_attendance_id and not employee.last_attendance_id.check_out and 'checked_in' or 'checked_out'
att = employee.last_attendance_id.sudo()
employee.attendance_state = att and not att.check_out and 'checked_in' or 'checked_out'
@api.constrains('pin')
def _verify_pin(self):