[REF] crm: Refactored stage changes.
authoruco (OpenERP) <uco@tinyerp.com>
Fri, 10 Dec 2010 06:24:35 +0000 (11:54 +0530)
committeruco (OpenERP) <uco@tinyerp.com>
Fri, 10 Dec 2010 06:24:35 +0000 (11:54 +0530)
bzr revid: uco@tinyerp.com-20101210062435-rj0x2wbsdzb3m1t4

addons/crm/crm.py
addons/crm/crm_lead.py
addons/crm_claim/crm_claim.py

index 8564fa8..c3a4ef4 100644 (file)
@@ -146,7 +146,7 @@ class crm_case(object):
         if not context:
             context = {}
         stage_pool = self.pool.get('crm.case.stage')
-        stage_type = context and context.get('stage_type','lead') or self._name.split('.')[1]
+        stage_type = context and context.get('stage_type','')
         current_seq = False
         for case in self.browse(cr, uid, ids, context):
             next_stage = False
@@ -184,7 +184,7 @@ class crm_case(object):
         if not context:
             context = {}
         stage_pool = self.pool.get('crm.case.stage')
-        stage_type = context and context.get('stage_type','lead') or self._name.split('.')[1]
+        stage_type = context and context.get('stage_type','')
         for case in self.browse(cr, uid, ids, context):
             prev_stage = False
             data = {}
index b71ef05..8cc45c7 100644 (file)
@@ -158,9 +158,11 @@ class crm_lead(crm_case, osv.osv):
         @param uid: the current user’s ID for security checks,
         @param context: A standard dictionary for contextual values
         """
-        type = context and context.get('stage_type', '') or ''
+        if context is None:
+            context = {}
+        type = context and context.get('stage_type', '')
         stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('type','=',type),('sequence','>=',1)])
-        return stage_ids and stage_ids[0]
+        return stage_ids and stage_ids[0] or False
 
     _defaults = {
         'active': lambda *a: 1,
index 4a7114c..cc6a1ac 100644 (file)
@@ -80,9 +80,11 @@ class crm_claim(crm.crm_case, osv.osv):
         @param uid: the current user’s ID for security checks,
         @param context: A standard dictionary for contextual values
         """
-        type = context and context.get('stage_type', '') or ''
+        if context is None:
+            context = {}
+        type = context and context.get('stage_type', '')
         stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('type','=',type),('sequence','>=',1)])
-        return stage_ids and stage_ids[0]
+        return stage_ids and stage_ids[0] or False
 
     _defaults = {
         'user_id': crm.crm_case._get_default_user,