From c088965a388605f393e7917a0afbc72704a8b275 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 7 Nov 2012 19:09:24 +0530 Subject: [PATCH] fixed atleast System Manager msg error --- core/doctype/profile/profile.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/doctype/profile/profile.py b/core/doctype/profile/profile.py index 16ee818e42..79ab671cb6 100644 --- a/core/doctype/profile/profile.py +++ b/core/doctype/profile/profile.py @@ -96,7 +96,8 @@ class DocType: # remove roles webnotes.conn.sql("""delete from tabUserRole where parent='%s' - and role in ('%s')""" % (self.doc.name, "','".join(self.temp['roles']['unset_roles']))) + and role in ('%s')""" % (self.doc.name, + "','".join(self.temp['roles']['unset_roles']))) if "System Manager" in self.temp['roles']['unset_roles']: self.check_one_system_manager() @@ -114,6 +115,11 @@ class DocType: def check_one_system_manager(self): if not webnotes.conn.sql("""select parent from tabUserRole where role='System Manager' and docstatus<2 and parent!='Administrator'"""): + if webnotes.conn.sql("""select count(*) from `tabProfile` + where name not in ('Administrator', 'Guest')""")[0][0] == 0: + self.temp["roles"]["set_roles"].append("System Manager") + return + webnotes.msgprint("""Cannot un-select as System Manager as there must be atleast one 'System Manager'.""", raise_exception=1)