From c64656266f3d9d2ab67ed2a897d93008f7888323 Mon Sep 17 00:00:00 2001 From: "Audric Onockx (auon)" Date: Wed, 29 Dec 2021 15:24:24 +0000 Subject: [PATCH] [FIX] hr_holidays : allow user to submit past sick days Steps: - Users > Admin > Acces Rights > Human Resources - Time Off : empty - Time Off > a past day > Time Off Request wizard : - Time Off Type : Sick Time Off - Confirm Issue: - User Error : 'You must have manager rights to modify/validate a time off that already begun' Cause: - When creating the request, attachments are writen onto the record. - Yet the user do not have rights to write in hr_holidays. Fix: - sudo in the compute and inverse methods that write the attachments. opw-2714597 closes odoo/odoo#82311 X-original-commit: 9bc197fcf6c87678c82863706344e449b1cd69c1 Signed-off-by: Kevin Baptiste Signed-off-by: Onockx Audric (auon) --- addons/hr_holidays/models/hr_leave.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index ded99b4548e..d7a0c66cd60 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -201,8 +201,8 @@ class HolidaysRequest(models.Model): # To display in form view supported_attachment_ids = fields.Many2many( 'ir.attachment', string="Attach File", compute='_compute_supported_attachment_ids', - inverse='_inverse_supported_attachment_ids') - supported_attachment_ids_count = fields.Integer(compute='_compute_supported_attachment_ids') + inverse='_inverse_supported_attachment_ids', compute_sudo=True) + supported_attachment_ids_count = fields.Integer(compute='_compute_supported_attachment_ids', compute_sudo=True) # UX fields all_employee_ids = fields.Many2many('hr.employee', compute='_compute_all_employees') leave_type_request_unit = fields.Selection(related='holiday_status_id.request_unit', readonly=True) @@ -641,7 +641,7 @@ class HolidaysRequest(models.Model): def _inverse_supported_attachment_ids(self): for holiday in self: - holiday.attachment_ids = holiday.supported_attachment_ids + holiday.sudo().attachment_ids = holiday.supported_attachment_ids @api.constrains('date_from', 'date_to', 'employee_id') def _check_date(self):