Strange Issue: Print Icon Disappeared

29%20AM

Recently on one of the instance, the print icon has disappeared… [Note for all doctypes]

  1. Roles are proper (Running from administrator and the roles has print permission from the doctype. (As such this issue is for all doc types
  2. Allow print in Draft mode in on from print settings. And once again the button like I said is not visible in any doc type whether submittable or not.
  3. I check JS console, console errors.
  4. Tried bench update --build to check if building the assets again workout, but in vain.
  5. instance is in production mode.

I have tried looking all known angles. Anyone have idea kindly guide on urgent basis please.

Regards,

Parth.

Is there any customizations using Custom Script on that instance. Also please share the exact version of Frappe and ERPNext

@netchampfaris Thanks for the reply. Appreciate your time.

Seems to be frappe version issues.

My Local machine has :

frappe 10.1.33

and my host machine had

frappe 10.1.28

Now I guess that there was something wrong in JS. So Digged in and found this toolbar.js which constructs the print icon. It has some code snippet like this:

    // Print
		if(!is_submittable || docstatus == 1  ||
			(allow_print_for_cancelled && docstatus == 2)||
			(allow_print_for_draft && docstatus == 0)) {
			if(frappe.model.can_print(null, me.frm)) {
				this.page.add_menu_item(__("Print"), function() {
					me.frm.print_doc();}, true);
				this.print_icon = this.page.add_action_icon("fa fa-print", function() {
					me.frm.print_doc();});
			}
		}

The frappe.model.can_print(null, me.frm) was returning null.

The can_print() callback is part of model.js which does something like this:

...
can_print: function(doctype, frm) {
		if(frm) return frm.perm[0].print===1;
		return frappe.boot.user.can_print.indexOf(doctype)!==-1;
	},
...

Now the condition here in JS is checking frm.perm[0].print as 1 where as in if I debug in console the value of frm.perm[0].print comes out to be true

So I figured out should be frappe version issue. Update the frappe and seems to be working fine now.

Any ideas why was this happening ?

Regards,

Parth

@surajshetty might have some ideas about this issue.

Let me know,

What’s output for frappe.model.can_print(null, cur_frm) from browser console on that page?

Are you able to see print option in under Menu button?

Also, reconfirm if following condition in the code satisfied

Best,
Suraj

Thanks @surajshetty for the reply. Appreciate your time.

  1. frappe.model.can_print(null, cur_frm) was returning false.
  2. Thats because the result of return frm.perm[0].print in can_print() in model.js is coming as true and not 1 (we are comparing it with 1 and not boolean)
  3. No I am not getting print from Menu Button as well.

Somehow I Updated Frappe and it fixed the issue. But I am not sure what was the issue and what was the root cause behind if so that someone else could also resolve the issue if the root cause is known.

Regards,

Parth Joshi

@ROHAN_JAIN1 please let us know the status of your document (either its draft, submitted or cancelled) which you to print and post the screenshot of your print settings.

Note Global search for print settings to view your print settings.