def set_default_role(doc, method):
 if frappe.flags.setting_role:
  return
 contact_name = frappe.get_value(u'Contact', dict(email_id=doc.email))
 if contact_name:
  contact = frappe.get_doc(u'Contact', contact_name)
  for link in contact.links:
   frappe.flags.setting_role = True
   if (link.link_doctype == u'Customer'):
    doc.add_roles(u'Customer')
   elif (link.link_doctype == u'Supplier'):
    doc.add_roles(u'Supplier')
 elif frappe.get_value(u'Student', dict(student_email_id=doc.email)):
  doc.add_roles(u'Student')

def set_default_role ( doc , method ) : if frappe . flags . setting_role : return contact_name = frappe . get_value ( u'Contact' , dict ( email_id = doc . email ) ) if contact_name : contact = frappe . get_doc ( u'Contact' , contact_name ) for link in contact . links : frappe . flags . setting_role = True if ( link . link_doctype == u'Customer' ) : doc . add_roles ( u'Customer' ) elif ( link . link_doctype == u'Supplier' ) : doc . add_roles ( u'Supplier' ) elif frappe . get_value ( u'Student' , dict ( student_email_id = doc . email ) ) : doc . add_roles ( u'Student' )
set customer .