"Website User" and add_role()

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.

Could it be because of these lines in setup?

def disable_desk_access_for_student_role():
try:
student_role = frappe.get_doc(“Role”, “Student”)
except frappe.DoesNotExistError:
create_student_role()
return

student_role.desk_access = 0
student_role.save()

def create_student_role():
student_role = frappe.get_doc({
“doctype”: “Role”,
“role_name”: “Student”,
“desk_access”: 0,
“restrict_to_domain”: “Education”
})
student_role.insert()

If that’s the case, can we just create a setup.py file up in the app folder? How can I make sure that it will get picked up appropriately?