From 08770d83c1c96a71beac90b0a66a3c91909c0d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 16 Oct 2013 12:58:55 +0200 Subject: [PATCH] [FIX] crm: fixed stage_find method. This method receives a domain for searching stages. However it adds a condition on the type of the stages independently of the received domain. It now creates a term for stage types only if not found in the domain given in parameter. bzr revid: tde@openerp.com-20131016105855-isq9frwp1fnquw4x --- addons/crm/crm_lead.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 9d17526c19f..9c7908a3b93 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -298,7 +298,7 @@ class crm_lead(format_address, osv.osv): '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.AVAILABLE_PRIORITIES[2][0], 'color': 0, - 'date_last_stage_update': fields.datetime.now(), + 'date_last_stage_update': fields.datetime.now, } _sql_constraints = [ @@ -351,10 +351,14 @@ class crm_lead(format_address, osv.osv): """ if isinstance(cases, (int, long)): cases = self.browse(cr, uid, cases, context=context) + if context is None: + context = {} + # check whether we should try to add a condition on type + avoid_add_type_term = any([term for term in domain if len(term) == 3 if term[0] == 'type']) # collect all section_ids section_ids = set() types = ['both'] - if not cases: + if not cases and context.get('default_type'): ctx_type = context.get('default_type') types += [ctx_type] if section_id: @@ -372,7 +376,8 @@ class crm_lead(format_address, osv.osv): search_domain.append(('section_ids', '=', section_id)) search_domain.append(('case_default', '=', True)) # AND with cases types - search_domain.append(('type', 'in', types)) + if not avoid_add_type_term: + search_domain.append(('type', 'in', types)) # AND with the domain in parameter search_domain += list(domain) # perform search, return the first found