Check times printed of doctype

Hello community,

I’d like to ask if it is possible to track how many times a doctype is printed ? (using specific print format or any print format)

Thank you.

Such a feature is possible but is not available by default. You’ll need to maintain a counter outside that doctype as you don’t want those doctypes to change each time you print.

Suppose I have created a counter outside that doctype, is it possible to do increment in jinja, e.g. by calling custom python function via HTTP request ? As far I know, we can’t use client side frappe.call inside jinja print format.

@michaeldvr you could add the code to increment counter in the “get_context” function in the “frappe/www/printview.py” file. It looks like this one function gets called in all cases where HTML based printing takes place(including PDFs). Adding your counter increment code here would mean you can enable this feature for any doctype and any print format with a toggle of a setting.

Also, you could inspiration from how ‘Track View’ feature has been developed in relation to how the tracked view counts show up in the timeline below the doc.

If you end up developing this feature please contribute it by opening a PR.

It’s possible to use client side frappe.call in john resig templating. Since it’s similar to jinja and works with similar calls, it should work.

Just curious what if the user goes to the document print view and doesn’t actually print the doc. then this approach would return erroneous results right? As in this approach cannot track the actual number of times the document was printed.