[FIX] crm: at lead creation, take into account the type given in vals to find the stage_id (if not provided) + refactoring of create() of tasks, project issues and leads
bzr revid: qdp-launchpad@openerp.com-20130115100353-z35mqrwij936n54s
This commit is contained in:
@@ -87,12 +87,13 @@ class crm_lead(base_stage, format_address, osv.osv):
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not vals.get('stage_id') and vals.get('section_id'):
|
||||
if not vals.get('stage_id'):
|
||||
ctx = context.copy()
|
||||
ctx['default_section_id'] = vals['section_id']
|
||||
if vals.get('section_id'):
|
||||
ctx['default_section_id'] = vals['section_id']
|
||||
if vals.get('type'):
|
||||
ctx['default_type'] = vals['type']
|
||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
|
||||
elif not vals.get('stage_id') and context.get('default_section_id'):
|
||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=context)
|
||||
return super(crm_lead, self).create(cr, uid, vals, context=context)
|
||||
|
||||
def _get_default_section_id(self, cr, uid, context=None):
|
||||
|
||||
@@ -1091,12 +1091,11 @@ class task(base_stage, osv.osv):
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not vals.get('stage_id') and vals.get('project_id'):
|
||||
if not vals.get('stage_id'):
|
||||
ctx = context.copy()
|
||||
ctx['default_project_id'] = vals['project_id']
|
||||
if vals.get('project_id'):
|
||||
ctx['default_project_id'] = vals['project_id']
|
||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
|
||||
elif not vals.get('stage_id') and context.get('default_project_id'):
|
||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=context)
|
||||
task_id = super(task, self).create(cr, uid, vals, context=context)
|
||||
self._store_history(cr, uid, [task_id], context=context)
|
||||
return task_id
|
||||
|
||||
@@ -67,12 +67,11 @@ class project_issue(base_stage, osv.osv):
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not vals.get('stage_id') and vals.get('project_id'):
|
||||
if not vals.get('stage_id'):
|
||||
ctx = context.copy()
|
||||
ctx['default_project_id'] = vals['project_id']
|
||||
if vals.get('project_id'):
|
||||
ctx['default_project_id'] = vals['project_id']
|
||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
|
||||
elif not vals.get('stage_id') and context.get('default_project_id'):
|
||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=context)
|
||||
return super(project_issue, self).create(cr, uid, vals, context=context)
|
||||
|
||||
def _get_default_project_id(self, cr, uid, context=None):
|
||||
|
||||
Reference in New Issue
Block a user