I want to modify some python code in Price List
. What is the best approach to do this?
I know I can modify directly the code, but in case I will upgrade to a later version the git pull will give me conflicts.
Do you have any idea?
You can contribute ur use case as a PR
I’m sorry, I did not understand you.
An example?
There is a function def validate
on erpnext/stock/doctype/price_list/price_list.py
I want to modify the code on validate function. But, I do not want to do it directly on that file since it will modify source code and it will give me problem when I upgrade.
@aldoblack First go throw this:
https://frappe.io/docs/user/en/tutorial
then set your custom validate method in hook.py:
doc_events = {
“Price List”: {
“validate”: “custom_app.custom_app.doctype.custom_doctype.validate_list” #path of validate method
}
}
It does not work.
I created a python fundtion:
def validate(self):
if not cint(self.buying) and not cint(self.selling):
throw(_("TEST"))
I tested the function if my path was correct with bench execute
I added in doc_events:
doc_events = {
"Price List": {
"validate": "energychoice_store.energy_choice_store.overriden_methods.price_list.validate"
}
}
I executed these commands:
bench clear-website-cache && bench restart && bench build && bench migrate
And still does not override the function.
You gave me a good idea but the thing is that it could not override.
So I modified a little bit by following these instructions:
Thank you for the help.