[IMP] rename methods in crm_lead and crm_phonecall:
in these classes, the method convert_partner() is now named handle_partner_assignation() also the method in crm_phonecall has received the same refactoring than the one in crm_lead documentation has been improved these two method are a pure code duplication and would deserve a refactoring bzr revid: abo@openerp.com-20121205192146-rogbsln3atcm1lvt
This commit is contained in:
parent
fdfb872c68
commit
1df211b693
|
@ -754,17 +754,18 @@ class crm_lead(base_stage, format_address, osv.osv):
|
|||
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):
|
||||
def handle_partner_assignation(self, cr, uid, ids, action='create', partner_id=False, context=None):
|
||||
"""
|
||||
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
|
||||
otherwise assign lead to the 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}
|
||||
"""
|
||||
#TODO this is a pure diplucation of the handle_partner_assignation method of crm_phonecall
|
||||
partner_ids = {}
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
# If the action is set to 'create' and no partner_id is set, create a new one
|
||||
|
|
|
@ -170,19 +170,23 @@ class crm_phonecall(base_state, osv.osv):
|
|||
'phone': phonecall.partner_phone,
|
||||
})
|
||||
|
||||
def convert_partner(self, cr, uid, ids, action='create', partner_id=False, context=None):
|
||||
def handle_partner_assignation(self, cr, uid, ids, action='create', partner_id=False, context=None):
|
||||
"""
|
||||
This function 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: phonecalls 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 = {}
|
||||
#TODO this is a pure diplucation of the handle_partner_assignation method of crm_lead
|
||||
partner_ids = {}
|
||||
force_partner_id = partner_id
|
||||
for call in self.browse(cr, uid, ids, context=context):
|
||||
if action == 'create':
|
||||
partner_id = force_partner_id or self._call_create_partner(cr, uid, call, context=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._call_create_partner(cr, uid, call, 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
|
||||
|
|
|
@ -33,4 +33,4 @@
|
|||
-
|
||||
!python {model: crm.lead}: |
|
||||
lead_ids = self.search(cr, uid, [('email_from','=', 'Mr. John Right <info@customer.com>')])
|
||||
self.convert_partner(cr, uid, lead_ids, context=context)
|
||||
self.handle_partner_assignation(cr, uid, lead_ids, context=context)
|
||||
|
|
|
@ -102,6 +102,6 @@ class crm_partner_binding(osv.osv_memory):
|
|||
lead_ids = context.get('active_ids', [])
|
||||
data = self.browse(cr, uid, ids, context=context)[0]
|
||||
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)
|
||||
return lead.handle_partner_assignation(cr, uid, lead_ids, data.action, partner_id, context=context)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue