[FIX] hr_recruitement: avoid crash when no res_model_id is given

This commit is contained in:
Jérome Maes
2017-09-18 16:25:15 +02:00
parent 596e88f05d
commit 245f259561
+1 -1
View File
@@ -20,7 +20,7 @@ class CalendarEvent(models.Model):
# sync res_model / res_id to opportunity id (aka creating meeting from lead chatter)
if 'applicant_id' not in defaults and defaults.get('res_id') and (defaults.get('res_model') or defaults.get('res_model_id')):
if (defaults.get('res_model') and defaults['res_model'] == 'hr.applicant') or self.env['ir.model'].sudo().browse(defaults['res_model_id']).model == 'hr.applicant':
if (defaults.get('res_model') and defaults['res_model'] == 'hr.applicant') or (defaults.get('res_model_id') and self.env['ir.model'].sudo().browse(defaults['res_model_id']).model == 'hr.applicant'):
defaults['applicant_id'] = defaults['res_id']
return defaults