[FIX] crm_lead: cleaned and uniformized won/lost
authorThibault Delavallée <tde@openerp.com>
Mon, 4 Nov 2013 11:57:35 +0000 (12:57 +0100)
committerThibault Delavallée <tde@openerp.com>
Mon, 4 Nov 2013 11:57:35 +0000 (12:57 +0100)
stage conditions.

bzr revid: tde@openerp.com-20131104115735-4bsv2l2n1c6q8jte

addons/crm/crm_lead.py

index cbe1005..5f52980 100644 (file)
@@ -74,8 +74,8 @@ class crm_lead(format_address, osv.osv):
             # this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages
             'crm.mt_lead_create': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.sequence <= 1,
             'crm.mt_lead_stage': lambda self, cr, uid, obj, ctx=None: (obj.stage_id and obj.stage_id.sequence > 1) and obj.probability < 100,
-            'crm.mt_lead_won': lambda self, cr, uid, obj, ctx=None: obj.probability == 100 and obj.stage_id and obj.stage_id.on_change,
-            'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.sequence > 1,
+            'crm.mt_lead_won': lambda self, cr, uid, obj, ctx=None: obj.probability == 100 and obj.stage_id and obj.stage_id.fold,
+            'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.fold and obj.stage_id.sequence > 1,
         },
     }
 
@@ -406,7 +406,7 @@ class crm_lead(format_address, osv.osv):
             :deprecated: this method will be removed in OpenERP v8.
         """
         for lead in self.browse(cr, uid, ids):
-            stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0), ('fold', '=', True), ('sequence', '>', 1)], context=context)
+            stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0), ('fold', '=', True)], context=context)
             if stage_id:
                 return self.write(cr, uid, [lead.id], {'stage_id': stage_id}, context=context)
             else: