[IMP] hr_holidays: use employee's partner to invite him to the event of his time-off

Events for time-off created with robodoo (demo data) wouldn’t invite the
partner related to a time off event as that partner didn’t have an user
counterpart. However, since he is an employee, he has a partner and can be
added to the event. This commit changes the check to fallback to the employee
partner if the user does not exist.

task-3455051
task-3389317

Part-of: odoo/odoo#138670
This commit is contained in:
Leonardo Pavan Rocha
2023-10-23 20:07:23 +00:00
parent 52dae7a2f0
commit 2bc3d44b8b
+3 -3
View File
@@ -1025,9 +1025,9 @@ class HolidaysRequest(models.Model):
'res_id': holiday.id,
}
# Add the partner_id (if exist) as an attendee
if user and user.partner_id:
meeting_values['partner_ids'] = [
(4, user.partner_id.id)]
partner_id = (user and user.partner_id) or (holiday.employee_id and holiday.employee_id.work_contact_id)
if partner_id:
meeting_values['partner_ids'] = [(4, partner_id.id)]
result[user.id].append(meeting_values)
return result