[FIX] mass convert oldest lead
bzr revid: tfr@openerp.com-20110411085120-xdjn8z046ak9enen
This commit is contained in:
parent
b11a71fd87
commit
047b10f0ff
|
@ -48,11 +48,10 @@ class crm_lead2opportunity_partner(osv.osv_memory):
|
|||
"""
|
||||
lead_obj = self.pool.get('crm.lead')
|
||||
|
||||
|
||||
res = super(crm_lead2opportunity_partner, self).default_get(cr, uid, fields, context=context)
|
||||
opportunities = res.get('opportunity_ids') or []
|
||||
|
||||
partner_id = False
|
||||
email = False
|
||||
for lead in lead_obj.browse(cr, uid, opportunities, context=context):
|
||||
partner_id = lead.partner_id and lead.partner_id.id or False
|
||||
email = re.findall(r'([^ ,<@]+@[^> ,]+)', lead.email_from or '')
|
||||
|
@ -150,7 +149,7 @@ class crm_lead2opportunity_partner(osv.osv_memory):
|
|||
subject = "lead %s converted into opportunity" % lead.name
|
||||
body = "Info \n Id : %s \n Subject: %s \n Partner: %s \n Description : %s " % (lead.id, lead.name, lead.partner_id.name, lead.description)
|
||||
try :
|
||||
tools.email_send(email_from, email_to, subject, body)
|
||||
tools.email_send(email_from, [email_to], subject, body)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -211,7 +210,7 @@ class crm_lead2opportunity_partner(osv.osv_memory):
|
|||
if data.name == 'merge' and (len(data.opportunity_ids) > 1 or not context.get('mass_convert') ):
|
||||
merge_obj = self.pool.get('crm.merge.opportunity')
|
||||
self.write(cr, uid, ids, {'opportunity_ids' : [(6,0, [data.opportunity_ids[0].id])]}, context=context)
|
||||
context.update({'lead_ids' : record_id})
|
||||
context.update({'lead_ids' : record_id, "convert" : True})
|
||||
return merge_obj.merge(cr, uid, data.opportunity_ids, context=context)
|
||||
|
||||
return {
|
||||
|
|
|
@ -73,7 +73,6 @@ class crm_lead2partner(osv.osv_memory):
|
|||
|
||||
data = list(context and context.get('active_ids', []) or [])
|
||||
res = super(crm_lead2partner, self).default_get(cr, uid, fields, context=context)
|
||||
|
||||
for lead in lead_obj.browse(cr, uid, data, context=context):
|
||||
partner_ids = []
|
||||
# Find partner address matches the email_from of the lead
|
||||
|
|
|
@ -61,7 +61,11 @@ class crm_merge_opportunity(osv.osv_memory):
|
|||
|
||||
|
||||
def find_oldest(self, cr, uid, op_ids, context=None):
|
||||
if not context:
|
||||
context = {}
|
||||
ids = [op_id.id for op_id in op_ids]
|
||||
if context.get('convert'):
|
||||
ids = list(set(ids) - set(context.get('lead_ids', False)) )
|
||||
lead_obj = self.pool.get('crm.lead')
|
||||
op_id = lead_obj.search(cr, uid, [('id', 'in', ids)], order='create_date' , context=context)
|
||||
opps = lead_obj.browse(cr, uid, [op_id[0]], context=context)
|
||||
|
@ -74,7 +78,7 @@ class crm_merge_opportunity(osv.osv_memory):
|
|||
opp_obj = self.pool.get('crm.lead')
|
||||
message_obj = self.pool.get('mailgate.message')
|
||||
|
||||
lead_ids = context and context.pop('lead_ids', []) or []
|
||||
lead_ids = context and context.get('lead_ids', []) or []
|
||||
|
||||
if len(op_ids) <= 1:
|
||||
raise osv.except_osv(_('Warning !'),_('Please select more than one opportunities.'))
|
||||
|
|
Loading…
Reference in New Issue