How to edit core doctypes like DocType or User?

Before anyone says “its not safe”, please know that I know the risk and I intend to use this solely for development purposes.

There are certain things I like to change up to speed up my developments as I have been creating a lot of apps lately.

You can customize the doctype but you can’t delete the field from the doctype or change the field type because

If you want to add the field then you can’t add it via custom field. because “Custom Fields cannot be added to core DocTypes”

You have to make a code for the add custom field in the core doctype when install the custom app.

reference:

1 Like

Hi,

Once upon a time, I’ve put, in custom application after_install hook, some SQL query that change User Core DocType property “show_title_field_in_link” to 1 and title_field to “full_name”.
First everything seems to be OK, and the User linked fields show what I want, but after deep UI tests strange errors messages show up… after investigate the root cause was “minor” changes of User DocType done by the custom app

As you said, you’r aware of what your doing, so with custom app and may be a fork will be a solution

1 Like

Hi:

Some customization is doable with property setters.

As @NCP well-said above, adding custom fields is not possible without changing core_doctypes_list … But is just needed on develop side, to creating custom app, not on “production” side.

Anyway, I chose that way sometimes and I am still alive :joy:
Hope this helps.

1 Like

Hi all,

I’m a bit confused about the purpose / objectives / differences between:

  1. Adding fields to doctypes via code as you outline here
  2. Using property setters
  3. Using custom docPerms

Is there anywhere that explains the use case for each? For example:

  1. What’s the recommended way to create a role permission for a custom app’s roles on an existing doctype (like Customer or Item)?

  2. What’s the recommended way for a custom app to add a field to an existing doctype (like Customer)?

You can export the role permission using the bench export-fixtures

Reference:

You can add the custom field in the customer and export it using the bench export-fixtures, but if you want to add the custom field in the this doctype then you have to follow the process that i provided in the above post.

Thanks for this. So, just to be clear, if I’m trying to add a permission on a custom role (call it “Production Manager”) to have select access on the Customer DocType, then I should have a Customer fixture?

My understanding was that I should use a Custom DocPerm. I’ve create a fixture for that per below, but every time I update the app on the server, this custom role loses its permissions on the Customer table. Is this the wrong approach? If so, what’s the Custom DocPerm for?

{
“amend”: 0,
“cancel”: 0,
“create”: 0,
“delete”: 0,
“docstatus”: 0,
“doctype”: “Custom DocPerm”,
“email”: 0,
“export”: 0,
“if_owner”: 0,
“import”: 0,
“modified”: “2024-06-16 21:06:29.995514”,
“name”: “mu6r5s5sdk”,
“parent”: “Customer”,
“permlevel”: 0,
“print”: 0,
“read”: 0,
“report”: 0,
“role”: “Production Manager”,
“select”: 1,
“share”: 0,
“submit”: 0,
“write”: 0
}