From 1680b171a31b0f42e04b613ea97966717887455a Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Fri, 12 Jul 2019 10:29:52 +0200 Subject: [PATCH] [FIX] hr: Fix departure wizard activity generation Purpose ======= If the fired employee has no access to the hr.employee model, the departure wizard will lead to a traceback, as we try to create an activity on a model for which the user won't be able to resolve it. Create an activity on the related partner instead. --- addons/hr/wizard/hr_departure_wizard.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/hr/wizard/hr_departure_wizard.py b/addons/hr/wizard/hr_departure_wizard.py index 70405c5b04d..c01b00c7fba 100644 --- a/addons/hr/wizard/hr_departure_wizard.py +++ b/addons/hr/wizard/hr_departure_wizard.py @@ -30,10 +30,13 @@ class HrDepartureWizard(models.TransientModel): employee.departure_reason = self.departure_reason employee.departure_description = self.departure_description + if not employee.user_id.partner_id: + return + for activity_type in self.plan_id.plan_activity_type_ids: self.env['mail.activity'].create({ - 'res_id': employee.id, - 'res_model_id': self.env['ir.model']._get('hr.employee').id, + 'res_id': employee.user_id.partner_id.id, + 'res_model_id': self.env['ir.model']._get('res.partner').id, 'activity_type_id': activity_type.activity_type_id.id, 'summary': activity_type.summary, 'user_id': activity_type.get_responsible_id(employee).id,