From 822d1b3d1310280a440366fdc6432ae6c02bdedc Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 1 Feb 2013 11:47:28 +0100 Subject: [PATCH] crm merge fix bzr revid: al@openerp.com-20130201104728-35rh2flvyjq8pxkn --- addons/crm/wizard/crm_lead_to_opportunity.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index e7129c98d6c..acff3e7b877 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -62,15 +62,11 @@ class crm_lead2opportunity_partner(osv.osv_memory): ids = [] if partner_id: # Search for opportunities that have the same partner and that arent done or cancelled - ids = lead_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', '=', 'opportunity'), '!', ('state', 'in', ['done', 'cancel'])]) + ids = lead_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', '=', 'opportunity')]) if ids: opportunities.append(ids[0]) - if not partner_id: - if email: - # Find email of existing opportunity matching the email_from of the lead - cr.execute("""select id from crm_lead where type='opportunity' and - substring(email_from from '([^ ,<@]+@[^> ,]+)') in (%s)""" % (','.join(email))) - ids = map(lambda x:x[0], cr.fetchall()) + if email: + ids = lead_obj.search(cr, uid, [('email', 'ilike', email), ('type', '=', 'opportunity')]) if ids: opportunities.append(ids[0])