Printing after completion, immediately

127 views
Skip to first unread message

Martin Schönbeck

unread,
Jan 28, 2020, 5:44:17 AM1/28/20
to iDempiere
Hi,

we want to print invoices etc. immediately after completing the corresponding document. The natural way is to add the printing into the workflow. But at the moment this doesn't work, because printing is done with Jasper Reports and doesn't see latest version of the document because it's not committed. And even it could see it, we don't want to have documents printed, which are not committed.

Anything is fine, if you are willing to wait 60 to 120 seconds. Then before printing a wait can be inserted and the workflow processor will only see the committed hint to proceed. But that's too long.

Therefore I'm going to implement a solution which I then want to move into the core and therefore I suggest different solutions to find the best.

Variant 1: add a new Activity to workflow which stops, waits for committing and restarts (Wait 0 could be an alternative but wouldn't be totally upward compatible). So the wait could simply be replaced by this activity and all behind it would work on the committed data.

Variant 2: implement the yet open subworkflow with type 'asynchron' (or a new type) placing the subworkflow into a queue which is executed immediately after committing.

Variant 3: any other ideas?

Please give me a hint in which direction to go.

Regards
Martin

Aziz Kayoueche

unread,
Jan 28, 2020, 3:20:10 PM1/28/20
to iDempiere
Hi
i don't know if that will help you but with the process of generating invoices, at the end of this process, there will be a pop-up window that gives you the choice of printing the document or not, maybe you can change the idea and create a process.

Carlos Antonio Ruiz Gomez

unread,
Jan 28, 2020, 5:05:03 PM1/28/20
to idem...@googlegroups.com
Martin, an idea, not tested, if I understand you correctly you're trying
to print automatically the invoice on the same Process_Invoice workflow.

So, what if instead of printing on that workflow you create a new
workflow with type "Document Value" that is triggered when completing
the invoice - I think those workflows are triggered after commit, so in
theory it must work.

Regards,

Carlos Ruiz


Am 28.01.20 um 11:44 schrieb Martin Schönbeck:

Syed

unread,
Jan 30, 2020, 3:55:19 AM1/30/20
to iDempiere
Hi Martin,

If there is no approval workflow for the completion of invoice then you can complete it using a button by calling the Report & Process which should be configured with Process class to complete the invoice and the respective Jasper report .

I hope this will be helpful to you.

Martin Schönbeck

unread,
Jan 30, 2020, 9:46:26 AM1/30/20
to iDempiere
Hi Carlos,


Am Dienstag, 28. Januar 2020 23:05:03 UTC+1 schrieb Carlos Antonio Ruiz Gomez:
Martin, an idea, not tested, if I understand you correctly you're trying
to print automatically the invoice on the same Process_Invoice workflow.

The invoice was an example, shipments and inoutconfirmations are at the moment more important.
 
So, what if instead of printing on that workflow you create a new
workflow with type "Document Value" that is triggered when completing
the invoice - I think those workflows are triggered after commit, so in
theory it must work.

I was sure it runs within the transaction, but I tested again (and found that way a missing transaction-handling in our serverprint plugin) and the workflow runs within the transaction for sure. But even if not, that wouldn't help on inoutconfirmations. There the confirmation header is completly constructed before adding the lines so I had to test (with SQL=) for having a confirmation line for every shipment line. But of course even that didn't work because of the open transaction.

I think, the version with a new or extended 'wait' action is easiest to understand, use and even to implement, so I tend to this solution.

Regards
Martin
 

 

Carlos Antonio Ruiz Gomez

unread,
Jan 30, 2020, 10:51:00 AM1/30/20
to idem...@googlegroups.com

Hi Martin, new idea.

What about the attached ReportStarterTrx.patch

Not tested, but I think that way it sets the transaction for jasper to use the transaction of the workflow.

Regards,

Carlos Ruiz



Am 30.01.20 um 15:46 schrieb Martin Schönbeck:
ReportStarterTrx.patch

Martin Schönbeck

unread,
Jan 30, 2020, 2:24:20 PM1/30/20
to iDempiere
Hi Carlos,


Am Donnerstag, 30. Januar 2020 16:51:00 UTC+1 schrieb Carlos Antonio Ruiz Gomez:

Hi Martin, new idea.

What about the attached ReportStarterTrx.patch

Not tested, but I think that way it sets the transaction for jasper to use the transaction of the workflow.

Regards,

Carlos Ruiz


I had considered this, too. That of course would help to get the documents generated. But the document is then not only printed but also sent via mail. I don't want to send documents which are not persisted in the database.

Regards
Martin

Carlos Antonio Ruiz Gomez

unread,
Jan 30, 2020, 2:37:44 PM1/30/20
to idem...@googlegroups.com
You could call the commit within the jasper report.


Am 30.01.20 um 20:24 schrieb Martin Schönbeck:

Martin Schönbeck

unread,
Jan 30, 2020, 2:55:18 PM1/30/20
to iDempiere
Hi Carlos


Am Donnerstag, 30. Januar 2020 20:37:44 UTC+1 schrieb Carlos Antonio Ruiz Gomez:
You could call the commit within the jasper report.


Does that mean, it wouldn't rise any problems, to commit in between that way? Will I have to open a new transaction then or will it under the old name proceed up to their end?

Then I probably would commit before starting the report. Then I also don't have to transfer the transaction to jasper.

Regards
Martin

Carlos Antonio Ruiz Gomez

unread,
Jan 30, 2020, 3:02:56 PM1/30/20
to idem...@googlegroups.com
It would rise problems if you do some post-process that requires a full rollback on failure.

But, I guess is not your case, printing the report means that is the last step of your workflow and if printed it must not be rolled back after.

Yes, committing before starting the report can also work without changes to actual core.

Regards,

Carlos Ruiz



Am 30.01.20 um 20:55 schrieb Martin Schönbeck:
--

Martin Schönbeck

unread,
Jan 31, 2020, 10:57:02 AM1/31/20
to iDempiere


Am Donnerstag, 30. Januar 2020 21:02:56 UTC+1 schrieb Carlos Antonio Ruiz Gomez:
It would rise problems if you do some post-process that requires a full rollback on failure.

But, I guess is not your case, printing the report means that is the last step of your workflow and if printed it must not be rolled back after.

Yes, committing before starting the report can also work without changes to actual core.

I have no tested this method with invoices. Because 'generate invoices (manual)' doesn't start the document workflows I had to use a document value workflow with @docstatus@=CO. It managed to generate the correct document and to put it into archive, but that got lost, because there was a transaction error later in the generation process. To test it again I tried to reverse the document and after the next transaction error I had to valid documents, one with negatve amounts persisted in the database. After some further test I decided to implement the continuation after commit. So when the time to wait is set to -1 the workflow will proceed after the commit using the TrxEventListener. It works like a charm and should have done that in the first place.

I would prefer to have it in the core, it doesn't change the behaviour as long as you don't enter a -1 into a wait, so it's compatible. I just have to learn how to generate pull requests for a part of our changes.

Regards
Martin

Heng Sin Low

unread,
Mar 9, 2020, 10:38:23 PM3/9/20
to idem...@googlegroups.com
Hi Carlos,

Regardless of the final approach decided by Martin, I think the ReportStarterTrx patch you attached here is a bug fix that should get applied to core.

Regards,
Low


--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/7062e2a4-6d75-bae2-6033-1eb6ab12383f%40gmail.com.
Reply all
Reply to author
Forward
0 new messages