I’ve recently moved all of my custom doctypes to a new app, which is all backed up to github. The client scripts that I had created in ERPNext have all been moved over to my custom app’s source code… all apart from 2 scripts, which are for core modules (Customer, and Address).
I’m wondering what the best practice is for working with scripts for core doctypes? The reading I’ve done suggests that one shouldn’t make changes to core doctypes (customer.js, for example) as changes will be lost when you update ERPNext.
Is there a way to manage my customer and address scripts so that I can pull/push changes to git like I do with my custom app?
That’s not the reason people advise against it. You can definitely make changes to core DocTypes without losing them during updates. You just have to be willing to spend time doing git merging. It’s the savings in time + effort that fuels these suggestions.
But for anyone who’s previously worked with an ERP using a compiled programming language? Merging code modifications is a fact of life, and the -only- way to upgrade.
Frappe/ERPNext are able to skip this step(*), because they’re based on a pair of interpreted programming languages: Python and Javascript. This introduces some interesting tricks, which are used with advantage by hooks.py, Customization, Server and Client scripts, etc. They allow us to split the code into different places: original, appended, and overwritten.
There are both advantages and disadvantages to this approach. It potentially saves a lot of time, and makes concepts like App Stores much easier. But it can also introduce unexpected runtime errors, and makes it difficult to clearly see the entire code set.
Hi all… running into a problem with my prod environment.
I’ve made changes to the js file I’ve got in my custom app, which applies changes to core doctypes (customer, address etc). As above, I’ve included this script in the hooks.py file for my custom app, however I can only see the changes applied when I move back to development.
Sir , every time i need to create .js files in public folder ? … eg. if i want to add filter on sales order , sales invoice … i created one file in public folder doctype_filters.js and call in hooks file shall i write filter for both doctype in same file doctype_filters.js or should i make both different files ?