How To Hide Print Button With Script from Sales Invoice

How To Hide Print Button With Script from Salse Invoice
with permission role

1 Like

Hi @msiam,

Please apply custom/client script.
If use the role set in the condition then will hide some options from the desk.

frappe.ui.form.on('Sales Invoice', {
	refresh(frm) {
	    if (frappe.user_roles.indexOf("Sales User") ==-1) {
	        $("button[data-original-title=Print]").hide();
	     }
	}
});

Then reload and check it.

Thank You!

5 Likes

Thank you its working fine

when i change the language the code does not work
the “print” translate so the code does not work how could we solve it?
@NCP

Well, you should probably change to code to accommodate the language change:

frappe.ui.form.on('Sales Invoice', {
	refresh(frm) {
		if (frappe.user_roles.indexOf("Sales User") ==-1) {
			var print_lst=["print","Impression"...] //or any other word that maybe on the button
			for (var i = 0; i < print_lst; i++) {
				elem = $("button[data-original-title=" + print_lst[i] + "]");
				if (elem.length){
					elem.hide();
				}  
			}
		}
	}
});

i what it to be enable translate just
not static list

maybe try:

elem = $("use[href=#icon-printer]").parent().parent();

¯\(ツ)

$( `[data-original-title="${__("Print")}"]`)

i use this and worked
thx @NCP @abrefael :+1: