Hi is there another workarround to override class py for non doctype and non whitelist def method? anyone
thanks
Hi is there another workarround to override class py for non doctype and non whitelist def method? anyone
thanks
I think this is unsupported way … but it works
Sample to override boot (non doctype class / whitelisted method)
On hooks.py
add:
import frappe.boot
import your_module.utils
frappe.boot.get_user_info = your_module.utils.custom_get_user_info
On your utils.py
file
from frappe.boot import add_user_info
import frappe
@frappe.whitelist()
def custom_get_user_info():
print("----------------------- I am here! Where are you? ----------------------")
user_info = frappe._dict()
add_user_info(frappe.session.user, user_info)
if frappe.session.user == "Administrator" and user_info.Administrator.email:
user_info[user_info.Administrator.email] = user_info.Administrator
return user_info
Or even cleaner way :
from frappe.boot import get_user_info as original_get_user_info
import frappe
@frappe.whitelist()
def custom_get_user_info():
print("----------------------- I am here! Where are you? ----------------------")
return original_get_user_info()
Hope this helps.
Thanks, will try this
Thank you