Customize doctypes and mantain customization during updates

Hello all,

I will try to explain some doubts I have with ERPNext. I would like to change projects naming mode to “field:project_name” (something that should be easy according to documentation), so I can go to “Customize Form” and change “autoname” property. No problem, but now I have a field called “naming_series” which is no longer used for anything. I try to make this field non-mandatory and hide it, but the system refuse to do that because it’s a mandatory field in the “standard doctype”. Then, It should be possible to change the doctype using “Customize Doctype”, but I can’t save changes in standard doctypes because I’m not in developer mode. I could still switch to developer mode, but in that case, are doctype changes lost when updating via “bench update”?

It seems to me that frappe/erpnext has a lot of customization option, but only “Customize Form” is usable for long-lasting changes over time and updates. Am I missing something? I think the above customization should be easy to do. What is the best approach to customize frappe/erpnext when small changes to core doctypes or code is needed and want to mantain compatibility during updates? Is it only advisable to use “Customize Form” (it has limitations)?

I want to understand the different customization options and the problems that may occur during an update. What happens if you make a change in the code of a controller and then execute “bench update”? A lot of answers in the forum suggest doing changes to code.

Thanks in advance :slight_smile:

Hi there,

It’s true that you can’t make a mandatory field non-mandatory, but you can set a default value and hide the field from view. It’d be nice to have a bit more control over standard forms, but it’s a tough balance because other doctypes may assume those fields are used and valid.

For controller methods, you should create a custom app and use hooks.py to override the core class.

https://frappeframework.com/docs/v13/user/en/python-api/hooks#override-doctype-class

Thank you very much peterg. Now I understand that a mandatory field can’t be hidden without a default value. It make sense.

I still have pending to learn how to use hooks.py in a custom app to override the core class. Do you know any simple app that serves as an example?

1 Like