As we know in frappe/ERPNext, there’s internal js file inside doctype folder and also js files under fixtures folder and both can be used to customize the client side behavior.
I still wonder until now: what’s the difference between those files? when to use the the fixtures one and the internal js for a doctype.
I need a proper answer please, some examples will be appreciated
This file is created when new doctype is created. If you are the creator of the app and doctype, use this js file directly.
Fixtures :
Any DocType can be exported as fixtures. Need to specify doctype and filters in hooks.py of custom app. bench export-fixtures command is used to export the fixtures. Make sure you filter fixtures before exporting or it will export all fixtures from all apps causing conflicts. Custom Script is not recommended to be exported as fixture if you already have a custom app.
Best way to extend current js script with custom app is to use doctype_js hook.
You are right, it works the same way also for Standard Doctypes, thanks!
I added doctype_js = {"Quotation" : "public/js/Quotation.js"}
to apps/custom_app/custom_app/hooks.py and custom script code to apps/custom_app/custom_app/public/js/Quotation.js, removed script from the fixtures and reinstalled app.
I have one more question - is exporting Standard Doctype as a fixture good practice/update-proof?
If I have to make change to Standard Doctype (ie change naming for Project to series, which cannot be done in customize form), I found the only way to put this change to the custom app via exporting whole Doctype as a fixture. Is it safe from the point of future updates to new versions?
I thought I was asking about topic regarding customization best practices, but sorry for that. I copied it to new topic, could you please response there? Thanks a lot!