Move Core Doctype to Custom App?

ERPNext Version 13

For core doctypes, what would happen if I change the Module to one of my custom apps and install it to another instance?

So far I found that the core doctype still exists in frappe-bench/apps/erpnext, and a new doctype was also created under my custom app directory.

Will there be any further conflicts down the road?

I have made some edits in core doctypes (not customize form, I know, thus cannot use property setter&fixtures), changing module seems like the only way to move the changes to another instance.

If there’s any other way to achieve this, I’d really appreciate. There’re too many edits to simply resume back to customize form and export customization.

Thanks in advance!

Editing the core doctype gets messy and will require you to maintain a separate fork of the code. The intended way to do this would be with a doctype class override hook:
https://frappeframework.com/docs/v14/user/en/python-api/hooks#override-doctype-class

1 Like

Thank you so much! I totally overlooked the hooks. However, it seems to only override the .py and .js file. Is there a way to override the .json file for the core DocType in app? I am not planning to update my current instance.

I recommend you do this with fixtures, basically all the changes you made to the original erpnext doctype will be saved with the help of fixtures in your custom app. When loading this app into another instance the changes you made to the original doctype will be implemented.

Here is a video of Karani Geoffrey (the legend himself) explaining how to do this:

https://www.youtube.com/watch?v=cQYAeUjVF8c&ab_channel=KaraniGeoffrey

Also as this comment here states, it is a nightmare to maintain overridden code:

https://discuss.frappe.io/t/extend-inherit-existing-doctype-from-a-custom-app/115991/2?u=julez

Here is another relevant comment:
https://discuss.frappe.io/t/how-to-set-an-existing-doctype-into-your-costum-app/77533/3?u=julez

However there are some core doctypes that frappe does not allow to customize (for example doctype “User”). You can edit them, but this wont persist and will be gone on installing an update. However it is possible to export changes with fixtures, as described in this post:

https://discuss.frappe.io/t/add-custom-fields-to-users/114578/2?u=julez