From bfbaa092688c6282ae8468ab0cb6bfc2fcdfc552 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 25 Oct 2018 11:46:21 +0200 Subject: [PATCH] [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 --- addons/hr_attendance/models/hr_attendance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_attendance/models/hr_attendance.py b/addons/hr_attendance/models/hr_attendance.py index e8772aeba10..55fbcf9102e 100644 --- a/addons/hr_attendance/models/hr_attendance.py +++ b/addons/hr_attendance/models/hr_attendance.py @@ -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,