From 2d48690f55afedc4d6a7d678506728101fb41ea5 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 30 Jan 2012 11:29:39 +0100 Subject: [PATCH] [FIX] crm: change probability of opportunity when changing stage in kanban view bzr revid: rco@openerp.com-20120130102939-bcfnwx945mxqxylj --- addons/crm/crm_lead.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index f479ed8d3a6..b17fa31ac91 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -841,17 +841,21 @@ class crm_lead(crm_case, osv.osv): if 'date_closed' in vals: return super(crm_lead,self).write(cr, uid, ids, vals, context=context) - if 'stage_id' in vals and vals['stage_id']: - stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, vals['stage_id'], context=context) - text = _("Changed Stage to: %s") % stage_obj.name + if vals.get('stage_id'): + stage = self.pool.get('crm.case.stage').browse(cr, uid, vals['stage_id'], context=context) + # change probability of lead(s) if required by stage + if not vals.get('probability') and stage.on_change: + vals['probability'] = stage.probability + text = _("Changed Stage to: %s") % stage.name self.message_append(cr, uid, ids, text, body_text=text, context=context) - message='' for case in self.browse(cr, uid, ids, context=context): - if case.type == 'lead' or context.get('stage_type',False)=='lead': - message = _("The stage of lead '%s' has been changed to '%s'.") % (case.name, stage_obj.name) + if case.type == 'lead' or context.get('stage_type') == 'lead': + message = _("The stage of lead '%s' has been changed to '%s'.") % (case.name, stage.name) + self.log(cr, uid, case.id, message) elif case.type == 'opportunity': - message = _("The stage of opportunity '%s' has been changed to '%s'.") % (case.name, stage_obj.name) - self.log(cr, uid, case.id, message) + message = _("The stage of opportunity '%s' has been changed to '%s'.") % (case.name, stage.name) + self.log(cr, uid, case.id, message) + return super(crm_lead,self).write(cr, uid, ids, vals, context) crm_lead()