Override standard controller methods in erpnext with custom app like (calculate_contribution method in selling controller)
In your custom app custom_app/custom_app/__int__.py
file
For Example
from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
from custom_app...<path_to_file> import calculate_item_values
calculate_taxes_and_totals.calculate_item_values = calculate_item_values
@jamsheer Hello brother, I’ve tried to add the first line(from erpnext.controllers…) that you’ve mentioned. But I don’t know how to set path for the custom path? What is that custom path means(from custom_app…<path_to_file> import )? Could you please elaborate this?
Thanks in advance!!!
Custom app means the frappe app that you created
That worked, thanks
This article helped me
@jamsheer hello brother, if that is overriding the py file, do i need to also override the js/controllers/taxes_and_totals.js?
did you able to override controller methods of erpnext, if yes then please help?
I want to override erpnext.PointOfSale.Controller = class {
check_stock_availability() {}
}
I don’t know why have you mentioned it as closed but here it is:
- Create the overrides folder in your project and your ide will include (or it is already included) init.py
- start by importing the class of the method (or the Doctype) you are overriding and define your class as mySubClass(FrappeErpnextBuiltInClass)
- once you define the overriden method in your custom overriding class, the FrappeErpnextBuiltInClass method will be overridden by the method you define in mySubClass method.
- go find hooks.py in your custom app root folder, there you will need to define overriding classes such as below:
override_doctype_class = {
"Frappe Erpnext Built In Class ": "customersproject.overrides.mySubClass.mySubClass"
}
Notice the doctype notation. Hope this sheds some light on what you are doing.