Print event, “printed” flag

there’s no built-in “printed” flag by default , how can we solve that without customize the frappe app?
is there any way to do that from another app using hooks?

You can create a table containing fields “printed” CHECK and “what is printed” LINK or DYNAMIC LINK and enter the data needed to keep track.

You could create a Tag “printed” and attach it to printed documents.

You could enter a comment under the printed document containing a text logging it having been printed.

There also is an on_print_pdf hook which might be useful, depending on your use case.

You could also try to find a central print funnel in the code of whatever frappe app combination you use.

The general problem with tracking printing on paper is that the paper is sorting the digital realm, and many things can go wrong from the print command to having the paper print duly and readably printed and diligently archived, transmitted, or whatever aspect of the print’s future is important to you. So some kind of external sensor or human or robot is needed to sensor the correctness of all this in order to set a “printed” flag corresponding to reality.

It is related to the legality of certain documents. For example, in some countries, when you print a sales invoice, the first printout is marked as “Original”, and any subsequent prints are marked as “Duplicate.” This ensures that only one original version exists.

I already have this implemented using a custom field and some customization in the Frappe printview file. However, now I want to achieve the same functionality without modifying Frappe’s core, ideally from an external app. I think the on_print_pdf hook might help with this.

What I would do is

  1. Create a “Print Log” doctype (on a separate app) with fields like print_doctype (link), print_docname (dynamic link), print_datetime (datetime), you can also add a print_user (link) and pass to it frappe.session.user
  2. Using Custom Jinja Methods, define a method that checks existing print log records and creates new ones
  3. Throw my jinja method in all print formats that require tracking

Depending on your use case, you might want the method to return bool if existing records were found (so you can use it in if-else Jinja block to hide print data) or simply return when was the last print datetime

I’m going to use this, but no need for log, a checkbox can be enough, also there is no hook called “on_print_pdf”,
thank you

Check this out

1 Like