How to add Button link in Doctype list View ? – Frappe Framework

by | May 30, 2021 | Frappe Framework | 1 comment

How to add Button link in Doctype list View ? {Direct link to specific Print Format} – Frappe Framework

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.

 

By Aadhil PM

1 Comments

1 Comment

  1. Sinu Jose

    Hi Aadhil, is it possible to have multiple button options like Pdf and Export to Excel or any other Action

    Reply

Submit a Comment

Your email address will not be published.