[IMP] remove the make_partner() method which wasn't in use anywhere anymore
bzr revid: abo@openerp.com-20121205171815-ztd21cjrfi0cy1vr
This commit is contained in:
parent
9f3688a692
commit
825472c6a7
|
@ -742,28 +742,38 @@ class crm_lead(base_stage, format_address, osv.osv):
|
|||
return partner_id
|
||||
|
||||
def _lead_set_partner(self, cr, uid, lead, partner_id, context=None):
|
||||
"""
|
||||
Assign a partner to a lead.
|
||||
|
||||
:param object lead: browse record of the lead to process
|
||||
:param int partner_id: identifier of the partner to assign
|
||||
:return bool: True if the partner has properly been assigned
|
||||
"""
|
||||
res = False
|
||||
res_partner = self.pool.get('res.partner')
|
||||
if partner_id:
|
||||
res_partner.write(cr, uid, partner_id, {'section_id': lead.section_id.id or False})
|
||||
contact_id = res_partner.address_get(cr, uid, [partner_id])['default']
|
||||
res = lead.write({'partner_id' : partner_id, }, context=context)
|
||||
res = lead.write({'partner_id': partner_id}, context=context)
|
||||
self._lead_set_partner_send_note(cr, uid, [lead.id], context)
|
||||
return res
|
||||
|
||||
def convert_partner(self, cr, uid, ids, action='create', partner_id=False, context=None):
|
||||
"""
|
||||
Convert partner based on action.
|
||||
Handle partner assignation during a lead conversion.
|
||||
if action is 'create', create new partner with contact and assign lead to new partner_id.
|
||||
otherwise assign lead to specified partner_id
|
||||
|
||||
:param list ids: leads/opportunities ids to process
|
||||
:param string action: what has to be done regarding partners (create it, assign an existing one, or nothing)
|
||||
:param int partner_id: partner to assign if any
|
||||
:return dict: dictionary organized as followed: {lead_id: partner_assigned_id}
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
partner_ids = {}
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
if action == 'create':
|
||||
if not partner_id:
|
||||
partner_id = self._create_lead_partner(cr, uid, lead, context)
|
||||
# If the action is set to 'create' and no partner_id is set, create a new one
|
||||
if action == 'create' and not partner_id:
|
||||
partner_id = self._create_lead_partner(cr, uid, lead, context)
|
||||
self._lead_set_partner(cr, uid, lead, partner_id, context=context)
|
||||
partner_ids[lead.id] = partner_id
|
||||
return partner_ids
|
||||
|
|
|
@ -10,16 +10,6 @@
|
|||
-
|
||||
!assert {model: crm.lead, id: crm.crm_case_4, string: Lead state is Open}:
|
||||
- state == "open"
|
||||
-
|
||||
I fill in a partner binding wizard.
|
||||
-
|
||||
!record {model: crm.partner.binding, id: crm_partner_binding_id1, context: '{"active_model": "crm.lead", "active_ids": [ref("crm_case_4")]}'}:
|
||||
-
|
||||
I create a partner from the partner binding wizard.
|
||||
-
|
||||
!python {model: crm.partner.binding}: |
|
||||
context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_4')], 'active_id': ref('crm_case_4')})
|
||||
self.make_partner(cr, uid ,[ref("crm_partner_binding_id1")], context=context)
|
||||
-
|
||||
I convert lead into opportunity for exiting customer.
|
||||
-
|
||||
|
|
|
@ -104,15 +104,4 @@ class crm_partner_binding(osv.osv_memory):
|
|||
partner_id = data.partner_id and data.partner_id.id or False
|
||||
return lead.convert_partner(cr, uid, lead_ids, data.action, partner_id, context=context)
|
||||
|
||||
def make_partner(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Make a partner based on action.
|
||||
Only called from form view, so only meant to convert one lead at a time.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
lead_id = context.get('active_id', 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)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue