From 4d94ce7fa541d813baa74c614b2f4759c8e5f3fe Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 26 Sep 2012 12:21:36 +0530 Subject: [PATCH] validate for max users only when enabling a user --- py/core/doctype/profile/profile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py/core/doctype/profile/profile.py b/py/core/doctype/profile/profile.py index da09fd59e7..c4778c6180 100644 --- a/py/core/doctype/profile/profile.py +++ b/py/core/doctype/profile/profile.py @@ -57,14 +57,15 @@ class DocType: def logout_if_disabled(self): """logout if disabled""" - if cint(self.doc.disabled): + if not cint(self.doc.enabled): import webnotes.login_manager webnotes.login_manager.logout(self.doc.name) def validate_max_users(self): """don't allow more than max users if set in conf""" import conf - if hasattr(conf, 'max_users'): + # check only when enabling a user + if hasattr(conf, 'max_users') and self.doc.enabled: active_users = webnotes.conn.sql("""select count(*) from tabProfile where ifnull(enabled, 0)=1 and docstatus<2 and name not in ('Administrator', 'Guest')""")[0][0]