'Try to find a matching partner regarding the active model data, like
the customer\'s name, email, phone number, etc.
:return int partner_id if any, False otherwise'

@api.model
def _find_matching_partner(self):

    if ((self._context.get('active_model') != 'crm.lead') or (not self._context.get('active_id'))):
        return False
    lead = self.env['crm.lead'].browse(self._context.get('active_id'))
    Partner = self.env['res.partner']
    if lead.partner_id:
        return lead.partner_id.id
    if lead.email_from:
        partner = Partner.search([('email', '=', lead.email_from)], limit=1)
        return partner.id
    if lead.partner_name:
        partner = Partner.search([('name', 'ilike', (('%' + lead.partner_name) + '%'))], limit=1)
        return partner.id
    if lead.contact_name:
        partner = Partner.search([('name', 'ilike', (('%' + lead.contact_name) + '%'))], limit=1)
        return partner.id
    return False
