Let’s say I want to override Address Doctype in frappe. It is already overridden in the hooks of ErpNext app. Also the validate method of Address is overridden in India Compliance app. Let’s say I have a custom app, dinakar-custom in which I want to write my own custom functionality of Address Doctype class. My site dinakarSite has erpnext, india-compliance and dinakar-custom installed. So which Address docType is chosen by frappe? Also is there a way to combine all the functionalities in my dinakar-custom app?
When multiple apps override the same DocType, the app that is loaded last will take precedence. In your case, if the Address Doctype is overridden in the hooks of the ERPNext app and the validate method is overridden in the India Compliance app, the version of Address from the dinakar-custom app will be chosen because it is the last app loaded.
Thanks for the reply. What do you mean by last app loaded? Does it mean the app that is installed last or if I just change the order of the app names in apps.txt file in site folder, the order of app loading gets changed?
The order in which the apps are listed in the
apps.txt file in the site folder determines the order in which the apps are loaded. The last app listed in the
apps.txt file will be loaded last.
So, if you want to change the precedence of the apps and override a DocType from a specific app, you can modify the order of the app names in the
apps.txt file (Locate the
apps.txt file in the site folder of your ERPNext installation.). By moving the
dinakar-custom app to the bottom of the list, it will be loaded last, and its version of the Address Doctype will take precedence over other apps’ versions.
After modifying the
apps.txt file and saving the changes, the app loading order will be updated accordingly the next time you start or restart your ERPNext instance.
We haven’t tried but check it.