'Link address based on owner'

def link_address(self):

    if ((not self.links) and (not self.is_your_company_address)):
        contact_name = frappe.db.get_value(u'Contact', {u'email_id': self.owner})
        if contact_name:
            contact = frappe.get_doc(u'Contact', contact_name)
            for link in contact.links:
                self.append(u'links', dict(link_doctype=link.link_doctype, link_name=link.link_name))
            return True
    return False
