[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 <kba@odoo.com>
Signed-off-by: Onockx Audric (auon) <auon@odoo.com>
This commit is contained in:
Audric Onockx (auon)
2022-01-06 11:45:27 +00:00
parent f27ce3c797
commit c64656266f
+3 -3
View File
@@ -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):