From e2c2f99d5cfba02ad865153ae3031529fd1d1514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 24 May 2012 18:19:55 +0200 Subject: [PATCH] [IMP] crm_lead: domain on stage_id is more precise, taking into account case_default flag and stage type. bzr revid: tde@openerp.com-20120524161955-1y5jhvozyld6tp3p --- addons/crm/crm_lead.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 484d9c289d2..55f124297c7 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -192,7 +192,9 @@ class crm_lead(crm_case, osv.osv): 'type':fields.selection([ ('lead','Lead'), ('opportunity','Opportunity'), ],'Type', help="Type is used to separate Leads and Opportunities"), 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True), 'date_closed': fields.datetime('Closed', readonly=True), - 'stage_id': fields.many2one('crm.case.stage', 'Stage', domain="['&', ('section_ids', '=', section_id), ('type', '=', type)]"), + 'stage_id': fields.many2one('crm.case.stage', 'Stage', + domain="['&', '|', ('section_ids', '=', section_id), ('case_default', '=', True),\ + '|', ('type', '=', type), ('type', '=', 'both')]"), 'user_id': fields.many2one('res.users', 'Salesperson'), 'referred': fields.char('Referred By', size=64), 'date_open': fields.datetime('Opened', readonly=True), @@ -219,7 +221,6 @@ class crm_lead(crm_case, osv.osv): 'date_deadline': fields.date('Expected Closing'), 'date_action': fields.date('Next Action Date', select=True), 'title_action': fields.char('Next Action', size=64), - 'stage_id': fields.many2one('crm.case.stage', 'Stage', domain="[('section_ids', '=', section_id)]"), 'color': fields.integer('Color Index'), 'partner_address_name': fields.related('partner_id', 'name', type='char', string='Partner Contact Name', readonly=True), 'partner_address_email': fields.related('partner_id', 'email', type='char', string='Partner Contact Email', readonly=True), @@ -291,8 +292,6 @@ class crm_lead(crm_case, osv.osv): if lead_section_id: domain += ['|', ('section_ids', '=', lead_section_id), ('case_default', '=', True)] stage_ids = self.pool.get('crm.case.stage').search(cr, uid, domain, order=order, context=context) - print domain - print stage_ids if stage_ids: return stage_ids[0] return False