From 2fdefd0f2112a401d066cf822b2fa7b588a6884d Mon Sep 17 00:00:00 2001 From: althaf shaik Date: Mon, 26 Jun 2023 09:34:01 +0000 Subject: [PATCH] [FIX] hr_attendance: restrict to compute worked hours without employee This traceback raises when user not selected 'Employee' and only selecting 'Check In' and 'Check Out', while creating a new attendance. To reproduce the issue: 1) Install hr_attendance 2) Open Attendance and create a new record 3) Give values to only 'Check In' and 'Check Out' Error: "AttributeError: 'bool' object has no attribute 'upper'" appears. On '_compute_worked_hours' method calendar variable is getting value from employee_id and that calendar timezone is used to get timezone. https://github.com/odoo/odoo/blob/937d207028ab9bc1d3d332dc6dfe25f0de045026/addons/hr_attendance/models/hr_attendance.py#L50-L60 Therefore in the above use case, when triggering the compute method, because of 'calendar' is depending on 'employee_id' and when employee is not selected, it will leads to the above traceback. Sentry-4274226351 closes odoo/odoo#126465 X-original-commit: 31491e40d2505c03d76e6c802435ad1dafa71c52 Signed-off-by: Kevin Baptiste --- 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 96dc22e9e41..c0dcfd3df98 100644 --- a/addons/hr_attendance/models/hr_attendance.py +++ b/addons/hr_attendance/models/hr_attendance.py @@ -54,7 +54,7 @@ class HrAttendance(models.Model): @api.depends('check_in', 'check_out') def _compute_worked_hours(self): for attendance in self: - if attendance.check_out and attendance.check_in: + if attendance.check_out and attendance.check_in and attendance.employee_id: calendar = attendance._get_employee_calendar() resource = attendance.employee_id.resource_id tz = timezone(calendar.tz)