IDEMPIERE-4523 - Process Audit not mark AD_PInstance.IsProcessing on simple Reports (#1343)

* IDEMPIERE-4523 - Process Audit not mark AD_PInstance.IsProcessing on simple Reports

* IDEMPIERE-4523 - fixed workflow use case
This commit is contained in:
Peter Takács 2022-06-02 10:15:39 +02:00 committed by GitHub
parent 20116c6144
commit bf32da5738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 166 additions and 120 deletions

View File

@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MPInstance;
import org.compiere.model.MProcess; import org.compiere.model.MProcess;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MTable; import org.compiere.model.MTable;
@ -217,36 +218,46 @@ public class ServerReportCtl {
static public boolean start (ProcessInfo pi) static public boolean start (ProcessInfo pi)
{ {
/** MPInstance instance = new MPInstance(Env.getCtx(), pi.getAD_PInstance_ID(), null);
* Order Print instance.setIsProcessing(true);
*/ instance.saveEx();
if (pi.getAD_Process_ID() == PROCESS_RPT_C_ORDER) // C_Order
return startDocumentPrint(ReportEngine.ORDER, null, pi.getRecord_ID(), null, pi); try {
if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt PP_Order", null)) // C_Order /**
return startDocumentPrint(ReportEngine.MANUFACTURING_ORDER, null, pi.getRecord_ID(), null, pi); * Order Print
if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt DD_Order", null)) // C_Order */
return startDocumentPrint(ReportEngine.DISTRIBUTION_ORDER, null, pi.getRecord_ID(), null, pi); if (pi.getAD_Process_ID() == PROCESS_RPT_C_ORDER) // C_Order
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice return startDocumentPrint(ReportEngine.ORDER, null, pi.getRecord_ID(), null, pi);
return startDocumentPrint(ReportEngine.INVOICE, null, pi.getRecord_ID(), null, pi); if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt PP_Order", null)) // C_Order
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut return startDocumentPrint(ReportEngine.MANUFACTURING_ORDER, null, pi.getRecord_ID(), null, pi);
return startDocumentPrint(ReportEngine.SHIPMENT, null, pi.getRecord_ID(), null, pi); if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt DD_Order", null)) // C_Order
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project return startDocumentPrint(ReportEngine.DISTRIBUTION_ORDER, null, pi.getRecord_ID(), null, pi);
return startDocumentPrint(ReportEngine.PROJECT, null, pi.getRecord_ID(), null, pi); else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse return startDocumentPrint(ReportEngine.INVOICE, null, pi.getRecord_ID(), null, pi);
return startDocumentPrint(ReportEngine.RFQ, null, pi.getRecord_ID(), null, pi); else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_DUNNING) // Dunning return startDocumentPrint(ReportEngine.SHIPMENT, null, pi.getRecord_ID(), null, pi);
return startDocumentPrint(ReportEngine.DUNNING, null, pi.getRecord_ID(), null, pi); else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project
else if (pi.getAD_Process_ID() == PROCESS_RPT_FINREPORT // Financial Report return startDocumentPrint(ReportEngine.PROJECT, null, pi.getRecord_ID(), null, pi);
|| pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse
return startFinReport (pi); return startDocumentPrint(ReportEngine.RFQ, null, pi.getRecord_ID(), null, pi);
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // M_Inventory else if (pi.getAD_Process_ID() == PROCESS_RPT_C_DUNNING) // Dunning
return startDocumentPrint(ReportEngine.INVENTORY, null, pi.getRecord_ID(), null, pi); return startDocumentPrint(ReportEngine.DUNNING, null, pi.getRecord_ID(), null, pi);
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_MOVEMENT) // M_Movement else if (pi.getAD_Process_ID() == PROCESS_RPT_FINREPORT // Financial Report
return startDocumentPrint(ReportEngine.MOVEMENT, null, pi.getRecord_ID(), null, pi); || pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement
/******************** return startFinReport (pi);
* Standard Report else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // M_Inventory
*******************/ return startDocumentPrint(ReportEngine.INVENTORY, null, pi.getRecord_ID(), null, pi);
return startStandardReport (pi); else if (pi.getAD_Process_ID() == PROCESS_RPT_M_MOVEMENT) // M_Movement
return startDocumentPrint(ReportEngine.MOVEMENT, null, pi.getRecord_ID(), null, pi);
/********************
* Standard Report
*******************/
return startStandardReport (pi);
}
finally {
instance.setIsProcessing(false);
instance.saveEx();
}
} // create } // create
/************************************************************************** /**************************************************************************

View File

@ -1159,40 +1159,47 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
// Process // Process
MProcess process = MProcess.get(getCtx(), m_node.getAD_Process_ID()); MProcess process = MProcess.get(getCtx(), m_node.getAD_Process_ID());
MPInstance pInstance = new MPInstance(getCtx(), process.getAD_Process_ID(), getRecord_ID()); MPInstance pInstance = new MPInstance(getCtx(), process.getAD_Process_ID(), getRecord_ID());
pInstance.setIsProcessing(true);
pInstance.saveEx(); pInstance.saveEx();
fillParameter(pInstance, trx); try {
// fillParameter(pInstance, trx);
ProcessInfo pi = new ProcessInfo (m_node.getName(true), m_node.getAD_Process_ID(), //
getAD_Table_ID(), getRecord_ID()); ProcessInfo pi = new ProcessInfo (m_node.getName(true), m_node.getAD_Process_ID(),
getAD_Table_ID(), getRecord_ID());
//check record id overwrite
MWFNodePara[] nParams = m_node.getParameters(); //check record id overwrite
for(MWFNodePara p : nParams) MWFNodePara[] nParams = m_node.getParameters();
{ for(MWFNodePara p : nParams)
if (p.getAD_Process_Para_ID() == 0 && p.getAttributeName().equalsIgnoreCase("Record_ID") && !Util.isEmpty(p.getAttributeValue(), true))
{ {
try if (p.getAD_Process_Para_ID() == 0 && p.getAttributeName().equalsIgnoreCase("Record_ID") && !Util.isEmpty(p.getAttributeValue(), true))
{ {
Object value = parseNodeParaAttribute(p); try
if (value == p || value == null) {
break; Object value = parseNodeParaAttribute(p);
int recordId = Integer.valueOf(value.toString()); if (value == p || value == null)
pi.setRecord_ID(recordId); break;
int recordId = Integer.valueOf(value.toString());
pi.setRecord_ID(recordId);
}
catch (NumberFormatException e)
{
log.log(Level.WARNING, e.getMessage(), e);
}
break;
} }
catch (NumberFormatException e)
{
log.log(Level.WARNING, e.getMessage(), e);
}
break;
} }
pi.setAD_User_ID(getAD_User_ID());
pi.setAD_Client_ID(getAD_Client_ID());
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
boolean success = process.processItWithoutTrxClose(pi, trx);
setTextMsg(pi.getSummary());
return success;
}
finally {
pInstance.setIsProcessing(false);
pInstance.saveEx();
} }
pi.setAD_User_ID(getAD_User_ID());
pi.setAD_Client_ID(getAD_Client_ID());
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
boolean success = process.processItWithoutTrxClose(pi, trx);
setTextMsg(pi.getSummary());
return success;
} }
/****** Start Task (Probably redundant; /****** Start Task (Probably redundant;

View File

@ -869,25 +869,32 @@ public class DashboardController implements EventListener<Event> {
int AD_Table_ID = 0; int AD_Table_ID = 0;
int Record_ID = 0; int Record_ID = 0;
// //
MPInstance pInstance = new MPInstance(Env.getCtx(), process.getAD_Process_ID(), Record_ID); MPInstance pInstance = new MPInstance(process, Record_ID);
pInstance.setIsProcessing(true);
pInstance.saveEx(); pInstance.saveEx();
fillParameter(pInstance, parameters); try {
// fillParameter(pInstance, parameters);
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), //
AD_Table_ID, Record_ID); ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(),
pi.setAD_User_ID(Env.getAD_User_ID(Env.getCtx())); AD_Table_ID, Record_ID);
pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx())); pi.setAD_User_ID(Env.getAD_User_ID(Env.getCtx()));
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID()); pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
if (!process.processIt(pi, null) && pi.getClassName() != null) pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
throw new IllegalStateException("Process failed: (" + pi.getClassName() + ") " + pi.getSummary()); if (!process.processIt(pi, null) && pi.getClassName() != null)
throw new IllegalStateException("Process failed: (" + pi.getClassName() + ") " + pi.getSummary());
// Report
ReportEngine re = ReportEngine.get(Env.getCtx(), pi); // Report
if (re == null) ReportEngine re = ReportEngine.get(Env.getCtx(), pi);
throw new IllegalStateException("Cannot create Report AD_Process_ID=" + process.getAD_Process_ID() if (re == null)
+ " - " + process.getName()); throw new IllegalStateException("Cannot create Report AD_Process_ID=" + process.getAD_Process_ID()
+ " - " + process.getName());
return re;
}
finally {
pInstance.setIsProcessing(false);
pInstance.saveEx();
}
return re;
} }
public AMedia generateReport(int AD_Process_ID, String parameters) throws Exception { public AMedia generateReport(int AD_Process_ID, String parameters) throws Exception {

View File

@ -167,13 +167,21 @@ public abstract class AbstractProcessCtl implements Runnable
*/ */
if (AD_Workflow_ID > 0) if (AD_Workflow_ID > 0)
{ {
startWorkflow (AD_Workflow_ID);
MPInstance pinstance = new MPInstance(Env.getCtx(), m_pi.getAD_PInstance_ID(), null); MPInstance pinstance = new MPInstance(Env.getCtx(), m_pi.getAD_PInstance_ID(), null);
String errmsg = m_pi.getSummary(); pinstance.setIsProcessing(true);
pinstance.setResult(!m_pi.isError());
pinstance.setErrorMsg(errmsg);
pinstance.saveEx(); pinstance.saveEx();
unlock(); try {
startWorkflow (AD_Workflow_ID);
String errmsg = m_pi.getSummary();
pinstance.setResult(!m_pi.isError());
pinstance.setErrorMsg(errmsg);
pinstance.saveEx();
unlock();
}
finally {
pinstance.setIsProcessing(false);
pinstance.saveEx();
}
return; return;
} }

View File

@ -136,48 +136,55 @@ public class ReportCtl
instance.setAD_PrintFormat_ID(((MPrintFormat)pi.getSerializableObject()).getAD_PrintFormat_ID()); instance.setAD_PrintFormat_ID(((MPrintFormat)pi.getSerializableObject()).getAD_PrintFormat_ID());
instance.setIsSummary(pi.isSummary()); instance.setIsSummary(pi.isSummary());
instance.setAD_Language_ID(pi.getLanguageID()); instance.setAD_Language_ID(pi.getLanguageID());
instance.setIsProcessing(true);
instance.saveEx(); instance.saveEx();
/** try {
* Order Print /**
*/ * Order Print
if (pi.getAD_Process_ID() == PROCESS_RPT_C_ORDER) // C_Order */
return startDocumentPrint(ReportEngine.ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); if (pi.getAD_Process_ID() == PROCESS_RPT_C_ORDER) // C_Order
if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt PP_Order", null)) // C_Order return startDocumentPrint(ReportEngine.ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
return startDocumentPrint(ReportEngine.MANUFACTURING_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt PP_Order", null)) // C_Order
if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt DD_Order", null)) // C_Order return startDocumentPrint(ReportEngine.MANUFACTURING_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
return startDocumentPrint(ReportEngine.DISTRIBUTION_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt DD_Order", null)) // C_Order
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice return startDocumentPrint(ReportEngine.DISTRIBUTION_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PAYMENT) // C_Payment return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PAYMENT) // C_Payment
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // Physical Inventory return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview());
return startDocumentPrint(ReportEngine.INVENTORY, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // Physical Inventory
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_MOVEMENT) // Inventory Move return startDocumentPrint(ReportEngine.INVENTORY, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_M_MOVEMENT) // Inventory Move
/** return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ /**
return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint); else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ
else if (pi.AD_Process_ID == 9999999) // PaySelection return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint);
return startDocumentPrint(CHECK, pi, IsDirectPrint); else if (pi.AD_Process_ID == 9999999) // PaySelection
else if (pi.AD_Process_ID == 9999999) // PaySelection return startDocumentPrint(CHECK, pi, IsDirectPrint);
return startDocumentPrint(REMITTANCE, pi, IsDirectPrint); else if (pi.AD_Process_ID == 9999999) // PaySelection
**/ return startDocumentPrint(REMITTANCE, pi, IsDirectPrint);
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_DUNNING) // Dunning **/
return startDocumentPrint(ReportEngine.DUNNING, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_C_DUNNING) // Dunning
else if (pi.getAD_Process_ID() == PROCESS_RPT_FINREPORT // Financial Report return startDocumentPrint(ReportEngine.DUNNING, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|| pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement else if (pi.getAD_Process_ID() == PROCESS_RPT_FINREPORT // Financial Report
return startFinReport (pi, WindowNo); || pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement
/******************** return startFinReport (pi, WindowNo);
* Standard Report /********************
*******************/ * Standard Report
return startStandardReport (pi, WindowNo); *******************/
return startStandardReport (pi, WindowNo);
}
finally {
instance.setIsProcessing(false);
instance.saveEx();
}
} // create } // create
/************************************************************************** /**************************************************************************

View File

@ -324,6 +324,8 @@ public class Process {
// Start // Start
if (process.isWorkflow()) if (process.isWorkflow())
{ {
pInstance.setIsProcessing(true);
pInstance.saveEx();
try try
{ {
int AD_Workflow_ID = process.getAD_Workflow_ID(); int AD_Workflow_ID = process.getAD_Workflow_ID();
@ -345,6 +347,10 @@ public class Process {
r.setIsError( true ); r.setIsError( true );
return res; return res;
} }
finally {
pInstance.setIsProcessing(false);
pInstance.saveEx();
}
} }
if (process.isJavaProcess() && !jasperreport) if (process.isJavaProcess() && !jasperreport)