[FIX] hr_attendance: allow multiple attendances

If the search returns more than one result, the rendering of the message would
crash (SingletonError when accessing check_in field value).

Use the same order and limit as both search before and after

Courtesy of David Tran

Closes odoo/odoo#28055
This commit is contained in:
Martin Trigaux
2018-10-25 11:49:15 +02:00
parent 8e63bcb47c
commit bfbaa09268
+1 -1
View File
@@ -81,7 +81,7 @@ class HrAttendance(models.Model):
('employee_id', '=', attendance.employee_id.id),
('check_out', '=', False),
('id', '!=', attendance.id),
])
], order='check_in desc', limit=1)
if no_check_out_attendances:
raise exceptions.ValidationError(_("Cannot create new attendance record for %(empl_name)s, the employee hasn't checked out since %(datetime)s") % {
'empl_name': attendance.employee_id.name_related,