Hiding Add button (without disabling create permissions)

Hello! For weird client purposes, I want to hide the “Add” button of a custom doctype from report view only but keep it in list view. Is this achievable via client script?
Screenshot 2023-01-15 225305

ERPNext V14 hosted on Frappe Cloud.


Create a client script, and apply to your doctype (List, not Form)

frappe.listview_settings['Inspection'] = {
	refresh: function(listview) {
	    if (frappe.get_route()[2] == 'Report'){

I’m sure that there are best and more elegant solutions, but I think this works :wink:
Hope this helps.

1 Like

Works! Thanks a lot

1 Like

This seems to work pretty well but sometimes when I open a document from the list view(where primary button is hidden), the save button(primary button of the form view) is also missing.

Often times have to refresh the page multiple times in order to get the save button back.

Any solution for this?