From b27333919ad5deb464093f72554d82d080c35ed3 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 17 Nov 2015 13:56:15 +0100 Subject: [PATCH] [FIX] crm; probability of a crm.lead record When creating a crm.lead record, the default probability of this record must be the the probability of its default stage. opw:654284 --- addons/crm/crm_lead.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index f23fb7a1262..9c014d971c6 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -59,6 +59,14 @@ class crm_lead(format_address, osv.osv): _inherit = ['mail.thread', 'ir.needaction_mixin', 'utm.mixin'] _mail_mass_mailing = _('Leads / Opportunities') + def _get_default_probability(self, cr, uid, context=None): + """ Gives default probability """ + stage_id = self._get_default_stage_id(cr, uid, context=None) + if stage_id: + return self.pool['crm.stage'].browse(cr, uid, stage_id, context=context).probability + else: + return 10 + def _get_default_stage_id(self, cr, uid, context=None): """ Gives default stage_id """ team_id = self.pool['crm.team']._get_default_team_id(cr, SUPERUSER_ID, context=context, user_id=uid) @@ -239,7 +247,7 @@ class crm_lead(format_address, osv.osv): 'team_id': lambda s, cr, uid, c: s.pool['crm.team']._get_default_team_id(cr, SUPERUSER_ID, context=c, user_id=uid), 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c), 'priority': lambda *a: crm_stage.AVAILABLE_PRIORITIES[0][0], - 'probability': 10, + 'probability': lambda s, cr, uid, c: s._get_default_probability(cr, uid, c), 'color': 0, 'date_last_stage_update': fields.datetime.now, }