How to hide the primary button in listview


I want to hide the primary action button in listview for doc Sales Order. How can I make it?image
Like the snapshot shows above, i’d like to hide button +Add Sales Order.



I’m assuming this change is needed for specific users ?
Then look at Role Permissions Manager to define who can create\add Sales Orders.

Hi @msalim79

My goal is let people create sales order from quotation instead of click add sales order directly.
So I just want to hide it.


After googled a lot. I found the solution
In my custom script of that doctype listview, add
$(’.btn-primary’).hide(); in onload: function(listview){}


Hi, I put that code in my file lease_contract_list.js with the following code but it’s not working.

frappe.listview_settings[‘Lease Contract’] = {
(’.btn-primary’).hide(); in onload: function(listview){}

You need to add it in Client Script

Thanks for the reply. I copied the code exactly but get a red cross with the error “Expected identifier and instead saw ‘in’.” I’ve tried multiple variations and I have also tried from list.js but to no avail.

Hi @gudiva,

Please apply it.

frappe.listview_settings['Lease Contract'].refresh = function(listview) {

Then reload and check it.


Thanks @NCP but when I try that I just get a blank page

I tried this code and removed the button in the middle of the page, but the top right hand button still persists

frappe.listview_settings[‘Lease Contract’] = {
onload: function(listview) {

It’s working on my side version 13.

@NCP thank you for your efforts.

What I have noticed is that the code does work on core doctypes but not those created from custom apps, which is what I was trying to do in my case. I created and tried the code on a new vanilla custom app and still the problem persists. I don’t know if this problem is inherent but I’ll try to debug and post my findings. Cheers guys