How to override get_toolbar() of treeview.js?

Hi,

I would like to override the get_toolbar() function of frappe.views.treeview.js. To be precisely I would like to override the click events of “Rename” and “Delete”. Currently these two event does not refresh the treeview after deleting or renaming. I would like to add me.make_tree() to refresh the treeview.

Currently I can hardcode the frappe treeview.js. But they will go away after bench update. Is there any way that I can override this function or these two event for my custom app only? any suggestion will be appreciated.

So I add

doctype_tree_js = {"Item Category" : "public/js/tree.js"}

in my custom app’s hooks.py and rewrite the get_toolbar() function in tree.js.

frappe.views.TreeView.get_toolbar = function () {
.....
};

However it does not work.