Error during document's workflows are not displayed on Workflow Activities form.

Description

SCENARIO
When an user approves a document that cannot be completed because of any validations, the error is not displayed.
Before aprove:

After aprove:

Despite that, we can check on log by using iDempiere Server Monitor, the errors actually accurs. Like showed below:

org.adempiere.exceptions.AdempiereException: Failed when processing document - No account defined for this organization / currency Create an account on the bank account window for the organization / currency, the POS payments will be created on the defined account at org.compiere.model.MOrder.createInvoice(MOrder.java:2326) at org.compiere.model.MOrder.completeIt(MOrder.java:1968) at org.compiere.process.DocumentEngine.completeIt(DocumentEngine.java:522) at org.compiere.process.DocumentEngine.processIt(DocumentEngine.java:325) at org.compiere.process.DocumentEngine.processIt(DocumentEngine.java:289) at org.compiere.model.MOrder.processIt(MOrder.java:1239) at org.compiere.wf.MWFActivity.performWork(MWFActivity.java:1080) at org.compiere.wf.MWFActivity.run(MWFActivity.java:926) at org.compiere.wf.MWFProcess.startNext(MWFProcess.java:422) at org.compiere.wf.MWFProcess.checkActivities(MWFProcess.java:279) at org.compiere.wf.MWFActivity.setWFState(MWFActivity.java:313) at org.compiere.wf.MWFActivity.setUserChoice(MWFActivity.java:1592)

Sales order after approval:

Notice that the Sales Order is not beeing completed by the workflow. Although, if we try to complete it again, the Sales Order falls on workflow again.


CAUSE
Analysing the WWFActivity form, it can be notice that there is a FDialog to popup any error.

Besides that, the thrown Excpetion is already catched before it hits try-catch statment above. Because of it, none Exceptions are displayed for user.


HOW TO ADJUST
It is quite simple. Since the exception message can be obtained by using the getProcessMsg() method available on MWFProcess, a simple throw new Exception(/* getProcessMsg() here*/) is enough, since it will be catched and displayed for user.


TEST CASE

Current behavior.
1. Approve a document with an error when trying to complete.
2. Notice that the error happens, but it is not displayed for final user.

After adjust
1. Approve a document with an error when trying to complete.
2. The error must be showed for end user.

Environment

Attachments

9

Activity

Marcos Favaretto 
March 28, 2023 at 12:23 PM
(edited)

Correction performed!

I have a Sales Order which can't be completed:

After user attempt to complete that document, as expected, it falls on Sales Order Workflow and waits for approve.

After approval, the exception is thrown at the Workflow Acitivities form.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Created March 23, 2023 at 5:48 PM
Updated August 1, 2023 at 5:26 PM
Resolved June 7, 2023 at 7:49 PM