Customizing User Doctype in Frappe Version 14

Dear Frappe community,

I am facing an issue with Frappe version 14 where I am unable to edit core and standard doctypes. Specifically, I am having trouble changing the user doctype. In the past, I would use the customize form tool, but it no longer allows me to make changes.

I am seeking advice on how to add more fields or edit existing ones in the user doctype. Additionally, I am open to suggestions on creating a new doctype in a new app that extends the user doctype by linking it with the user account. However, I would like to hide some of the core fields, without changing or adding new ones, to avoid confusion for my clients who may find duplicate fields in both doctypes.

To summarize, my main questions are:

  • How can I add more fields or edit existing ones in the user doctype in Frappe version 14?
  • Is it possible to hide specific core fields, without changing or adding new ones, to avoid confusion for clients?
  • Are there any alternative solutions to customizing the user doctype, such as creating a new doctype in a new app that extends the user doctype for linking it with the user?

I understand that these constraints may be in place to protect Frappe’s default functions, but I hope there is a way to achieve what I need without causing any issues.

Thank you in advance for any advice or suggestions you may have. I appreciate your expertise and support in resolving this issue.

I have a similar use case, I use a custom doctype to create a new user via server script.
Create a new doctype with the fields required then create a server script for the new doctype with Before Submit trigger. Then map your fields similar to the following script

if not doc.email:

    email = doc.username + "@aacms.com"
else:
    email = doc.email

aa = frappe.get_doc({
    "doctype": "User",
    "first_name": doc.first_name,
    "last_name": "",
    "email": email,
    "username": doc.username,
    "send_welcome_email": 0,
    "module_profile": doc.module_profiles,
    "roles": [
        {
            "role": doc.role_profile_name
        }
    ]
})
aa.flags.ignore_mandatory = True;
aa.run_method("onload");
aa.run_method("set_missing_value");
aa.insert();
aa.new_password = doc.get_password("password");
aa.save();
frappe.msgprint("A user with email " + email + " has been created");
# frappe.throw("ERROR ....");

Might not be the best solution but it works without any heavy customization.
Eid Mubarak!

2 Likes

Thank you for the suggestion,

Unfortunately, this solution won’t work for me. I still need a lot of details and fields in the core User Doctype. What i was thinking about is to only hide why I and my client don’t need. I though hiding would be easier for Frappe. And from the other side, I would extend the Core User Doctype by a new custom User Profile Doctype with my own custom fields that i need and make it one-to-one relationship.

The app will only be accessible by admins, so it will not be a big deal but it would be better if i can clean up the extra fields by hiding them. End-users will use the mobile application anyway.

Thank you!

did u find a solution?

Have you try DocType Layout ?

I tried it before, not sure it is stable yet.