Override core functions of frappe and not doctypes using Monkey Patch
Currently there is no way to override standard methods of DocType class.
Currently there is no way to override standard methods of DocType class.
There are a lot of discussions on this topic. And the suggested solution is this one:
https://discuss.erpnext.com/t/how-to-override-method-in-frappe/28786/4
This overrides the method directly by setting the method on the class object. If this line is not called in a method, then the method will stay after the request is complete, so if there are other sites that don't have that app installed, they will be affected by the custom method behavior.
You can now override a standard DocType class via hooks.
test_app/hooks.py
override_doctype_class = {
'ToDo': 'test_app.overrides.CustomToDo'
}
test_app/overrides.py
import frappefrom frappe.desk.doctype.todo.todo import ToDoclass CustomToDo(ToDo):
def on_update(self):
self.my_custom_code()
super(ToDo, self).on_update()
def my_custom_code(self):
pass
Docs Link: https://github.com/frappe/frappe_docs/pull/45/files#diff-059ec755822aab5a151ab63bb8792c10R388
Test
Who built this? why all strikethrough.
in init.py override working well
HI Apoorv,in
Why all text on this post is strikethrough?