diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index bbd7e3a56b9..bf9e83215df 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -84,6 +84,13 @@ class crm_lead(base_stage, format_address, osv.osv): }, } + def create(self, cr, uid, vals, context=None): + if not context.get('default_section_id', False) and vals.get('section_id', False): + ctx = context.copy() + ctx['default_section_id'] = vals['section_id'] + vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) + return super(crm_lead, self).create(cr, uid, vals, context=context) + def _get_default_section_id(self, cr, uid, context=None): """ Gives default section by checking if present in the context """ return (self._resolve_section_id_from_context(cr, uid, context=context) or False)