[FIX] crm: unify partner conversion wizards and make sure they work for batch mode

bzr revid: odo@openerp.com-20120425085659-0h14fymyh2km3pgf
This commit is contained in:
Olivier Dony 2012-04-25 10:56:59 +02:00
parent 82653f4b63
commit b606b1281c
4 changed files with 11 additions and 18 deletions

View File

@ -196,11 +196,11 @@ class crm_phonecall(crm_base, osv.osv):
if context is None:
context = {}
partner_ids = {}
force_partner_id = partner_id
for call in self.browse(cr, uid, ids, context=context):
if action == 'create':
if not partner_id:
partner_id = self._call_create_partner(cr, uid, call, context=context)
self._call_create_partner_address(cr, uid, call, partner_id, context=context)
partner_id = force_partner_id or self._call_create_partner(cr, uid, call, context=context)
self._call_create_partner_address(cr, uid, call, partner_id, context=context)
self._call_set_partner(cr, uid, [call.id], partner_id, context=context)
partner_ids[call.id] = partner_id
return partner_ids

View File

@ -107,15 +107,11 @@ class crm_lead2opportunity_partner(osv.osv_memory):
context = {}
lead = self.pool.get('crm.lead')
res = False
if context.get('mass_convert'):
partner_ids_map = self._create_partner(cr, uid, ids, context=context)
else:
partner_id = self._create_partner(cr, uid, ids, context=context)
partner_ids_map = self._create_partner(cr, uid, ids, context=context)
lead_ids = vals.get('lead_ids', [])
team_id = vals.get('section_id', False)
for lead_id in lead_ids:
if context.get('mass_convert'):
partner_id = partner_ids_map.get(lead_id, False)
partner_id = partner_ids_map.get(lead_id, False)
# FIXME: cannot pass user_ids as the salesman allocation only works in batch
res = lead.convert_opportunity(cr, uid, [lead_id], partner_id, [], team_id, context=context)
# FIXME: must perform salesman allocation in batch separately here

View File

@ -107,17 +107,16 @@ class crm_lead2partner(osv.osv_memory):
lead_ids = context and context.get('active_ids') or []
data = self.browse(cr, uid, ids, context=context)[0]
partner_id = data.partner_id and data.partner_id.id or False
partner_ids = lead.convert_partner(cr, uid, lead_ids, data.action, partner_id, context=context)
if context.get('mass_convert'):
return partner_ids
return partner_ids[lead_ids[0]]
return lead.convert_partner(cr, uid, lead_ids, data.action, partner_id, context=context)
def make_partner(self, cr, uid, ids, context=None):
"""
This function Makes partner based on action.
"""
partner_id = self._create_partner(cr, uid, ids, context=context)
return self.pool.get('res.partner').redirect_partner_form(cr, uid, partner_id, context=context)
# Only called from Form view, so only meant to convert one Lead.
lead_id = context and context.get('active_id') or False
partner_ids_map = self._create_partner(cr, uid, ids, context=context)
return self.pool.get('res.partner').redirect_partner_form(cr, uid, partner_ids_map.get(lead_id, False), context=context)
crm_lead2partner()

View File

@ -61,12 +61,10 @@ class crm_phonecall2partner(osv.osv_memory):
if context is None:
context = {}
phonecall = self.pool.get('crm.phonecall')
data = self.browse(cr, uid, ids, context=context)[0]
call_ids = context and context.get('active_ids') or []
partner_id = data.partner_id and data.partner_id.id or False
partner_ids = phonecall.convert_partner(cr, uid, call_ids, data.action, partner_id, context=context)
return partner_ids[call_ids[0]]
return phonecall.convert_partner(cr, uid, call_ids, data.action, partner_id, context=context)
crm_phonecall2partner()