From e1d1e1f2a5418fd5e6284f898758af936d4b4bd2 Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Mon, 6 Dec 2021 17:26:53 +0000 Subject: [PATCH] [FIX] hr_holidays_attendance: allow non HR officer user to refuse leaves When refusing a leave, we are deleting the associated overtime if any so it can be used again by the employee. However, we need HR Officer rights to access overtime field. The sudo() should be used before we try to read the field to avoid errors in case the manager of the employee does not have HR rights. closes odoo/odoo#80945 X-original-commit: 1ffbcf9787e5efe00d49f18baba0144f631ada51 Signed-off-by: Kevin Baptiste Signed-off-by: Alex Thuyls (alt) --- addons/hr_holidays_attendance/models/hr_leave.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_holidays_attendance/models/hr_leave.py b/addons/hr_holidays_attendance/models/hr_leave.py index 44af5d9974e..c9fb7e14749 100644 --- a/addons/hr_holidays_attendance/models/hr_leave.py +++ b/addons/hr_holidays_attendance/models/hr_leave.py @@ -77,5 +77,5 @@ class HRLeave(models.Model): def action_refuse(self): res = super().action_refuse() - self.overtime_id.sudo().unlink() + self.sudo().overtime_id.unlink() return res