In some cases, it is required to do change that should be in the ERPNext code for the doctype (for example, I need to do changes related to the item table in the sales order and purchase order, because I need the pricing to be in another way), but I do not this change to be removed by upgrade. Is there a method to resolve this?
I was think if there is inheritance method or a technique that enable me to change part of the code from another source file (this source file can be added by me, so it will not be overwrite when doing upgrade). How?
Customize Sales Order Item and Purchase Order Item via Customize Form. Also, make the same changes in Sales Invoice Item and Sales Invoice Item since you would want those to be reflected in the Invoices too.
Create a custom app, and export your fixtures there. Read more about them there are a number of posts regarding how to take fixtures etc. Add Custom Field, and Property Setter in your fixtures list in hooks.py in custom app and you are done. Now every time you upgrade erpnext, all your changes will remain safe.
Do you wish to add functionality or make changes to existing functionality ?
In case you wish to add more functionality (server-side) then you can add your Python Functions in a single file and keep them in your custom app. Later via Custom Scripts (which again you can export into fixtures) you can use these functions on appropriate events or conditions.
Thanks a lot for your kindly reply.
I can modify directly part of the ERPNext code, but it will be removed when doing upgrade. This is what I am looking to overcome it and that is why I was thinking in inheritance.
OK, if I need to add code in for adding new item and we all know that there is already event for adding new item, so which event will be run when adding new item? The event that I added in the customization or the original one?
I know that I can add new application in ERPNext and it will not be effected when doing upgrade. But maybe you were meaning something else, so can you explain what did you mean by this and what is the aim or advantage of what you mentioned?
Yes, this is useful for using new function without adding it to the ERPNext original code. But how I can modify method (python or java) of current ERPNext code without being removed in the upgrade.
By the way: Controllers is not helping in this direction?
Yes that will create conflicts when you do bench update and if done over a long period of time, the conflicts will become increasingly confusing.
I’ll tell you. Now ERPNext has default capabilities but every business will want ERPNext to include their process just like you.
Now the simplest or I’d say naive route is change all you want - i.e. code and doctypes. But then this creates problems when you want to update like you would want to go to v11 but you’ve done so many changes you get bogged down by the conflicts.
Hence, the first advice is to not change code (Python/JS anywhere in Frappe/ERPNext to suit your purpose) and do not edit doctypes via Edit Doctype for the default doctypes provided in ERPNext/Frappe. Instead you do Customize Form - you add customizations.
To save these customizations, there is a feature called Fixtures. It exports that doctype you specify complete with data you create.
If you wish to add new doctypes via Edit Doctype route you don’t add them to ERPNext’s default modules. You create new modules for your own app, and then add those new doctypes to your custom modules.
Hence in this way, default code and doctypes of ERPNext remain unchanged, and you get your business process into ERPNext too. Win Win !
Yes. You may also use the same for preserving some doctype entries which are required elsewhere.
However, one thing to remember is as the doctypes you export fixtures of increase in number, you will have to take care and maintain all of them. Ensure that your production server’s fixtures are always up to date, also your development branches that may stem from the production branch must have the same fixtures at all the time before deployment.
So while this is a useful feature, you also need to take care.
What is the best practice in case changes have to be made in Frappe DocTypes, which can’t be customized in Version 11? We can add new field types, but customizations can’t be exported to the custom app (AFAIK). e.g., we may need new new fields in the User DocType.