ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Customization that require change in the code, and the upgrade


#1

Hello;

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?

Regards
Bilal


#2

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.


Links


#3

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?

Regards
Bilal