summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ledoux <dle@openerp.com>2013-11-14 14:13:13 +0100
committerDenis Ledoux <dle@openerp.com>2013-11-14 14:13:13 +0100
commit7c1cb42e1769ea32fa79468a2d7dfe0ac28fd8a9 (patch)
tree7244b5099957480ade2168863bacb0b931434a8b
parentb61997e71671c7640ca3fe271804de46550c8502 (diff)
[FIX]crm: case_mark_lost and case_mark_won only were only setting the stage of the first lead passed, instead of the whole list.
bzr revid: dle@openerp.com-20131114131313-bml9m0ejsp82thjn
-rw-r--r--addons/crm/crm_lead.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 5f52980c8b0..9eaddc9fc0e 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -391,29 +391,43 @@ class crm_lead(format_address, osv.osv):
""" Mark the case as lost: state=cancel and probability=0
:deprecated: this method will be removed in OpenERP v8.
"""
- for lead in self.browse(cr, uid, ids):
+ stages_leads = {}
+ for lead in self.browse(cr, uid, ids, context=context):
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 0.0), ('fold', '=', True), ('sequence', '>', 1)], context=context)
if stage_id:
- return self.write(cr, uid, [lead.id], {'stage_id': stage_id}, context=context)
+ if stages_leads.get(stage_id):
+ stages_leads[stage_id].append(lead.id)
+ else:
+ stages_leads[stage_id] = [lead.id]
else:
raise osv.except_osv(_('Warning!'),
_('To relieve your sales pipe and group all Lost opportunities, configure one of your sales stage as follow:\n'
'probability = 0 %, select "Change Probability Automatically".\n'
'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.'))
+ for stage_id, lead_ids in stages_leads.items():
+ self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
+ return True
def case_mark_won(self, cr, uid, ids, context=None):
""" Mark the case as won: state=done and probability=100
:deprecated: this method will be removed in OpenERP v8.
"""
- for lead in self.browse(cr, uid, ids):
+ stages_leads = {}
+ for lead in self.browse(cr, uid, ids, 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)
+ if stages_leads.get(stage_id):
+ stages_leads[stage_id].append(lead.id)
+ else:
+ stages_leads[stage_id] = [lead.id]
else:
raise osv.except_osv(_('Warning!'),
_('To relieve your sales pipe and group all Won opportunities, configure one of your sales stage as follow:\n'
'probability = 100 % and select "Change Probability Automatically".\n'
'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.'))
+ for stage_id, lead_ids in stages_leads.items():
+ self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
+ return True
def case_escalate(self, cr, uid, ids, context=None):
""" Escalates case to parent level """