diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py index 00cc5184f3..286adbc441 100644 --- a/frappe/core/doctype/user/user.py +++ b/frappe/core/doctype/user/user.py @@ -316,7 +316,8 @@ class User(Document): # should be made up of characters, numbers and underscore only if not re.match(r"^[\w]+$", self.username): - frappe.throw(_("Username should not contain any special characters other than letters, numbers and underscore")) + frappe.msgprint(_("Username should not contain any special characters other than letters, numbers and underscore")) + self.username = "" def suggest_username(self): def _check_suggestion(suggestion): diff --git a/frappe/patches/v6_15/set_username.py b/frappe/patches/v6_15/set_username.py index bd787cffe1..4e62cad178 100644 --- a/frappe/patches/v6_15/set_username.py +++ b/frappe/patches/v6_15/set_username.py @@ -7,7 +7,7 @@ def execute(): users = frappe.db.sql_list("""select name from `tabUser` order by if(user_type='System User', 0, 1)""") for name in users: user = frappe.get_doc("User", name) - if user.username: + if user.username or not user.first_name: continue username = user.suggest_username()