From a7b5d2819dc7520422bab331eca445d1f27b4d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 29 Sep 2017 10:18:15 +0200 Subject: [PATCH] [FIX] crm: fix dict access Ensure key is present before taking its value in the defaults dict. --- addons/crm/models/calendar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/crm/models/calendar.py b/addons/crm/models/calendar.py index e341ec16688..136251bce71 100644 --- a/addons/crm/models/calendar.py +++ b/addons/crm/models/calendar.py @@ -18,7 +18,8 @@ class CalendarEvent(models.Model): # sync res_model / res_id to opportunity id (aka creating meeting from lead chatter) if 'opportunity_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'] == 'crm.lead') or self.env['ir.model'].sudo().browse(defaults['res_model_id']).model == 'crm.lead': + if (defaults.get('res_model') and defaults['res_model'] == 'crm.lead') or \ + (defaults.get('res_model_id') and self.env['ir.model'].sudo().browse(defaults['res_model_id']).model == 'crm.lead'): defaults['opportunity_id'] = defaults['res_id'] return defaults