Allow print for draft

I had disabled the Allow Print for Draft in the print settings, however I need to allow print for draft for only certain documents. Any possibility to achieve this either using client script or any other methods.

Hi @Rahul-R,

First, enable the Allow Print for Draft in Print Setting.
If don’t want to print in the Draft stage then apply it in a particular doctype.

Here we set in Purchase Order DocType.
So apply the client script.

frappe.ui.form.on('Purchase Order', {
    refresh: function(frm) {
        if(frm.doc.docstatus != 1) {
            $("button[data-original-title=Print]").hide();
            frm.page.menu.find('[data-label="Print"]').parent().parent().remove();
        }
    }
});

Also, remove the print option from the Menu list.

Output:

In Draft Stage:

After Submit:

Another Reference:

I hope this helps.

Thank You!

5 Likes

Dear @NCP , This solution hides print menu working fine.
But still system allows the user to print the document by pressing Cntrol+p. How to stop it?

Please try it.

When Control + p used then will print the doctype, not the document.

I tried, while i am inside sales invoice number 2, and by pressing cntrl+p, it is giving print format same when we click print button.

yes, it’s possible in v15, but it is not possible to open the document in v14. Code worked for v14, not 15.

Hi @ErpnextRaja,

And if you want to stop ctrl+p for version 14 and 15, then please apply the client script.

frappe.ui.keys.add_shortcut({
    shortcut: "ctrl+p",
    action: () => function(e) {
        return false;
    }
});

Thank You!

2 Likes

Thank You @NCP