'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 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}'

@api.multi
def handle_partner_assignation(self, action='create', partner_id=False):

    partner_ids = {}
    for lead in self:
        if lead.partner_id:
            partner_ids[lead.id] = lead.partner_id.id
            continue
        if (action == 'create'):
            partner = lead._create_lead_partner()
            partner_id = partner.id
            partner.team_id = lead.team_id
        if partner_id:
            lead.partner_id = partner_id
        partner_ids[lead.id] = partner_id
    return partner_ids
