[FIX] crm: at lead creation, take into account the type given in vals to find the...
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Tue, 15 Jan 2013 10:03:53 +0000 (11:03 +0100)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Tue, 15 Jan 2013 10:03:53 +0000 (11:03 +0100)
bzr revid: qdp-launchpad@openerp.com-20130115100353-z35mqrwij936n54s

addons/crm/crm_lead.py
addons/project/project.py
addons/project_issue/project_issue.py

index ab6770a..4455663 100644 (file)
@@ -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):
index 95f7771..f89ce83 100644 (file)
@@ -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
index 7b7b6f8..b0b7193 100644 (file)
@@ -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):