Skip to content
Snippets Groups Projects
Commit df01e563 authored by MerlinGuillaume's avatar MerlinGuillaume
Browse files

[FIX] hr_leave: validate leave in multi-company environment


Validating an employee's leave with multiple companies selected doesn't
work when the employee isn't part of one of the selected companies

Steps to reproduce:
1. Install Time Off
2. Go to General Settings > Companies and create another company
3. Connect as Marc Demo, open Time Off and create a new time off request
4. Connect as Mitchell Admin and go to Time Off > Managers > Time Off
5. Approve and validate the time off request of Marc Demo
6. An access error is raised: `Access to unauthorized or invalid
   companies.`

Solution:
Clear `allowed_company_ids` from the context when we create the
`calendar.event` to avoid raising the error

Problem:
The creation of the `calendar.event` didn't use the correct user's
`allowed_company_ids` in the context

opw-3052973

closes odoo/odoo#107085

Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
parent e51158dc
No related branches found
No related tags found
No related merge requests found
......@@ -890,6 +890,7 @@ class HolidaysRequest(models.Model):
meeting_values_for_user_id = meeting_holidays._prepare_holidays_meeting_values()
for user_id, meeting_values in meeting_values_for_user_id.items():
meetings += self.env['calendar.event'].with_user(user_id or self.env.uid).with_context(
allowed_company_ids=[],
no_mail_to_attendees=True,
active_model=self._name
).create(meeting_values)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment