Hello all,
I am trying to understand how I can create a user with a role and for that user to be a “Website User” (aka not a system user with desk access)
I have this example (almost copied totally from the student.py file)
def after_insert(self):
self.create_student_user()create student as website user
def create_student_user(self):
if not frappe.db.exists(“User”, self.student_email):
student_user = frappe.get_doc({
“doctype”: “User”,
“first_name”: self.first_name,
“last_name”: self.last_name,
“email”: self.student_email,
“gender”: self.gender,
“send_welcome_email”: 1,
“user_type”: “Website User”
})
student_user.flags.ignore_permissions = True
student_user.add_roles(“Student”)
student_user.save()
This indeed creates the user with the role of “Student” but it keeps the user type as system user.
I do not get how on erpnext, with almost the same code, once the student is created, it creates the equivalent user with student role AND website user for user type.
I does say on the user page:
"If the user has any role checked, then the user becomes a "System User". "System User" has access to the desktop"
But how does it work then for student?
I suspect I am missing something somewhere else… but I do not know where to look?
Thanks in advance for all help, pointers, etc.