How to add Button link in Doctype list View ? {Direct link to specific Print Format}
Step 1: Add the client script for on list view as below
This feature for apply to List is only available on Version 13
frappe.listview_settings['Invoice'] = {
button: {
show: function(doc) {
return true;
},
get_label: function() {
return __('PDF');
},
get_description: function(doc) {
return __('Print {0}', [doc.name])
},
action: function(doc) {
//frappe.set_route("/app/print/Invoice/" + doc.name);
var objWindowOpenResult = window.open(frappe.urllib.get_full_url("/api/method/frappe.utils.print_format.download_pdf?"
+ "doctype=" + encodeURIComponent("Invoice")
+ "&name=" + encodeURIComponent(doc.name)
+ "&trigger_print=0"
+ "&format=invoice print format"
+ "&no_letterhead=0"
+ "&_lang=en"
));
if(!objWindowOpenResult) {
msgprint(__("Please set permission for pop-up windows in your browser!")); return;
}
}
}
}
Step 2: The Button will be added to the list view of a particular doctype as shown below.
Reference: https://aadhilpm.com/button-link-in-doctype-list-view/