def get_system_managers(only_name=False):
 import email.utils
 from frappe.core.doctype.user.user import STANDARD_USERS
 system_managers = frappe.db.sql(u'select distinct name,\n DCTB  DCTB concat_ws(" ", if(first_name="", null, first_name), if(last_name="", null, last_name))\n DCTB  DCTB as fullname from tabUser p\n DCTB  DCTB where docstatus < 2 and enabled = 1\n DCTB  DCTB and name not in ({})\n DCTB  DCTB and exists (select * from tabUserRole ur\n DCTB  DCTB  DCTB where ur.parent = p.name and ur.role="System Manager")\n DCTB  DCTB order by creation desc'.format(u', '.join(([u'%s'] * len(STANDARD_USERS)))), STANDARD_USERS, as_dict=True)
 if only_name:
  return [p.name for p in system_managers]
 else:
  return [email.utils.formataddr((p.fullname, p.name)) for p in system_managers]

def get_system_managers ( only_name = False ) : import email . utils from frappe . core . doctype . user . user import STANDARD_USERS system_managers = frappe . db . sql ( u'select distinct name,\n DCTB  DCTB concat_ws(" ", if(first_name="", null, first_name), if(last_name="", null, last_name))\n DCTB  DCTB as fullname from tabUser p\n DCTB  DCTB where docstatus < 2 and enabled = 1\n DCTB  DCTB and name not in ({})\n DCTB  DCTB and exists (select * from tabUserRole ur\n DCTB  DCTB  DCTB where ur.parent = p.name and ur.role="System Manager")\n DCTB  DCTB order by creation desc' . format ( u', ' . join ( ( [ u'%s' ] * len ( STANDARD_USERS ) ) ) ) , STANDARD_USERS , as_dict = True ) if only_name : return [ p . name for p in system_managers ] else : return [ email . utils . formataddr ( ( p . fullname , p . name ) ) for p in system_managers ]
returns all system managers user details .