ERPNext Conference 2019* ERPNext.com Blog

Sales Order Permission for Status Button


#1

Referring to the title above and screenshot below, does anyone know how to set user permission for the “Status” button?


#2

Anyone?


#3
frappe.ui.form.on('Sales Order', {
  refresh : function(frm) {
    if (!has_common(frappe.user_roles, ["Administrator", "System Manager", "Central Operation"]))
    {
      setTimeout(() => {
      // frm.page.clear_menu()
      cur_frm.page.remove_inner_button(__('Close'),  __("Status"));      
      cur_frm.page.remove_inner_button(__('Re-open'),  __("Status"));      
      cur_list.page.clear_user_actions('Close')
    },100);
    
  }
    frm.remove_custom_button('Update Items')
  }
})

please refer this


#4

Thank you very much @sagar, it works! But I noticed that your script will remove ‘Update Items’, would you mind to show me how can I retain the ‘Update Items’ custom button?

I tried the below script but didn’t work:

frappe.ui.form.on('Sales Order', {
  refresh : function(frm) {
    if (!has_common(frappe.user_roles, ["Administrator", "System Manager", "Sales Manager"]))
    {
      setTimeout(() => {
      // frm.page.clear_menu()
      cur_frm.page.remove_inner_button(__('Close'),  __("Status"));  
      cur_frm.page.remove_inner_button(__('Hold'), __("Status"));
      cur_frm.page.remove_inner_button(__('Re-open'),  __("Status"));  
      cur_frm.page.remove_custom_button('Update Items');
      cur_list.page.clear_user_actions('Close');
    },100);
    
  }
  }
});