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:
parent
20116c6144
commit
bf32da5738
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MPInstance;
|
||||
import org.compiere.model.MProcess;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MTable;
|
||||
|
@ -217,36 +218,46 @@ public class ServerReportCtl {
|
|||
static public boolean start (ProcessInfo pi)
|
||||
{
|
||||
|
||||
/**
|
||||
* Order Print
|
||||
*/
|
||||
if (pi.getAD_Process_ID() == PROCESS_RPT_C_ORDER) // C_Order
|
||||
return startDocumentPrint(ReportEngine.ORDER, null, pi.getRecord_ID(), null, pi);
|
||||
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);
|
||||
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);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice
|
||||
return startDocumentPrint(ReportEngine.INVOICE, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut
|
||||
return startDocumentPrint(ReportEngine.SHIPMENT, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project
|
||||
return startDocumentPrint(ReportEngine.PROJECT, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse
|
||||
return startDocumentPrint(ReportEngine.RFQ, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_DUNNING) // Dunning
|
||||
return startDocumentPrint(ReportEngine.DUNNING, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_FINREPORT // Financial Report
|
||||
|| pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement
|
||||
return startFinReport (pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // M_Inventory
|
||||
return startDocumentPrint(ReportEngine.INVENTORY, null, pi.getRecord_ID(), null, 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);
|
||||
MPInstance instance = new MPInstance(Env.getCtx(), pi.getAD_PInstance_ID(), null);
|
||||
instance.setIsProcessing(true);
|
||||
instance.saveEx();
|
||||
|
||||
try {
|
||||
/**
|
||||
* Order Print
|
||||
*/
|
||||
if (pi.getAD_Process_ID() == PROCESS_RPT_C_ORDER) // C_Order
|
||||
return startDocumentPrint(ReportEngine.ORDER, null, pi.getRecord_ID(), null, pi);
|
||||
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);
|
||||
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);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice
|
||||
return startDocumentPrint(ReportEngine.INVOICE, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut
|
||||
return startDocumentPrint(ReportEngine.SHIPMENT, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project
|
||||
return startDocumentPrint(ReportEngine.PROJECT, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse
|
||||
return startDocumentPrint(ReportEngine.RFQ, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_DUNNING) // Dunning
|
||||
return startDocumentPrint(ReportEngine.DUNNING, null, pi.getRecord_ID(), null, pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_FINREPORT // Financial Report
|
||||
|| pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement
|
||||
return startFinReport (pi);
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // M_Inventory
|
||||
return startDocumentPrint(ReportEngine.INVENTORY, null, pi.getRecord_ID(), null, 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
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -1159,40 +1159,47 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
|||
// Process
|
||||
MProcess process = MProcess.get(getCtx(), m_node.getAD_Process_ID());
|
||||
MPInstance pInstance = new MPInstance(getCtx(), process.getAD_Process_ID(), getRecord_ID());
|
||||
pInstance.setIsProcessing(true);
|
||||
pInstance.saveEx();
|
||||
fillParameter(pInstance, trx);
|
||||
//
|
||||
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();
|
||||
for(MWFNodePara p : nParams)
|
||||
{
|
||||
if (p.getAD_Process_Para_ID() == 0 && p.getAttributeName().equalsIgnoreCase("Record_ID") && !Util.isEmpty(p.getAttributeValue(), true))
|
||||
try {
|
||||
fillParameter(pInstance, trx);
|
||||
//
|
||||
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();
|
||||
for(MWFNodePara p : nParams)
|
||||
{
|
||||
try
|
||||
if (p.getAD_Process_Para_ID() == 0 && p.getAttributeName().equalsIgnoreCase("Record_ID") && !Util.isEmpty(p.getAttributeValue(), true))
|
||||
{
|
||||
Object value = parseNodeParaAttribute(p);
|
||||
if (value == p || value == null)
|
||||
break;
|
||||
int recordId = Integer.valueOf(value.toString());
|
||||
pi.setRecord_ID(recordId);
|
||||
try
|
||||
{
|
||||
Object value = parseNodeParaAttribute(p);
|
||||
if (value == p || value == null)
|
||||
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;
|
||||
|
|
|
@ -869,25 +869,32 @@ public class DashboardController implements EventListener<Event> {
|
|||
int AD_Table_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();
|
||||
fillParameter(pInstance, parameters);
|
||||
//
|
||||
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(),
|
||||
AD_Table_ID, Record_ID);
|
||||
pi.setAD_User_ID(Env.getAD_User_ID(Env.getCtx()));
|
||||
pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
|
||||
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
|
||||
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);
|
||||
if (re == null)
|
||||
throw new IllegalStateException("Cannot create Report AD_Process_ID=" + process.getAD_Process_ID()
|
||||
+ " - " + process.getName());
|
||||
try {
|
||||
fillParameter(pInstance, parameters);
|
||||
//
|
||||
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(),
|
||||
AD_Table_ID, Record_ID);
|
||||
pi.setAD_User_ID(Env.getAD_User_ID(Env.getCtx()));
|
||||
pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
|
||||
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
|
||||
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);
|
||||
if (re == null)
|
||||
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 {
|
||||
|
|
|
@ -167,13 +167,21 @@ public abstract class AbstractProcessCtl implements Runnable
|
|||
*/
|
||||
if (AD_Workflow_ID > 0)
|
||||
{
|
||||
startWorkflow (AD_Workflow_ID);
|
||||
MPInstance pinstance = new MPInstance(Env.getCtx(), m_pi.getAD_PInstance_ID(), null);
|
||||
String errmsg = m_pi.getSummary();
|
||||
pinstance.setResult(!m_pi.isError());
|
||||
pinstance.setErrorMsg(errmsg);
|
||||
pinstance.setIsProcessing(true);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,48 +136,55 @@ public class ReportCtl
|
|||
instance.setAD_PrintFormat_ID(((MPrintFormat)pi.getSerializableObject()).getAD_PrintFormat_ID());
|
||||
instance.setIsSummary(pi.isSummary());
|
||||
instance.setAD_Language_ID(pi.getLanguageID());
|
||||
instance.setIsProcessing(true);
|
||||
instance.saveEx();
|
||||
|
||||
/**
|
||||
* 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() == MProcess.getProcess_ID("Rpt PP_Order", null)) // C_Order
|
||||
return startDocumentPrint(ReportEngine.MANUFACTURING_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt DD_Order", null)) // C_Order
|
||||
return startDocumentPrint(ReportEngine.DISTRIBUTION_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice
|
||||
return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut
|
||||
return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project
|
||||
return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse
|
||||
return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PAYMENT) // C_Payment
|
||||
return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // Physical Inventory
|
||||
return startDocumentPrint(ReportEngine.INVENTORY, 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.AD_Process_ID == 9999999) // PaySelection
|
||||
return startDocumentPrint(CHECK, 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_FINREPORT // Financial Report
|
||||
|| pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement
|
||||
return startFinReport (pi, WindowNo);
|
||||
/********************
|
||||
* Standard Report
|
||||
*******************/
|
||||
return startStandardReport (pi, WindowNo);
|
||||
try {
|
||||
/**
|
||||
* 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() == MProcess.getProcess_ID("Rpt PP_Order", null)) // C_Order
|
||||
return startDocumentPrint(ReportEngine.MANUFACTURING_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt DD_Order", null)) // C_Order
|
||||
return startDocumentPrint(ReportEngine.DISTRIBUTION_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice
|
||||
return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut
|
||||
return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project
|
||||
return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse
|
||||
return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PAYMENT) // C_Payment
|
||||
return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview());
|
||||
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // Physical Inventory
|
||||
return startDocumentPrint(ReportEngine.INVENTORY, 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.AD_Process_ID == 9999999) // PaySelection
|
||||
return startDocumentPrint(CHECK, 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_FINREPORT // Financial Report
|
||||
|| pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement
|
||||
return startFinReport (pi, WindowNo);
|
||||
/********************
|
||||
* Standard Report
|
||||
*******************/
|
||||
return startStandardReport (pi, WindowNo);
|
||||
}
|
||||
finally {
|
||||
instance.setIsProcessing(false);
|
||||
instance.saveEx();
|
||||
}
|
||||
} // create
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -324,6 +324,8 @@ public class Process {
|
|||
// Start
|
||||
if (process.isWorkflow())
|
||||
{
|
||||
pInstance.setIsProcessing(true);
|
||||
pInstance.saveEx();
|
||||
try
|
||||
{
|
||||
int AD_Workflow_ID = process.getAD_Workflow_ID();
|
||||
|
@ -345,6 +347,10 @@ public class Process {
|
|||
r.setIsError( true );
|
||||
return res;
|
||||
}
|
||||
finally {
|
||||
pInstance.setIsProcessing(false);
|
||||
pInstance.saveEx();
|
||||
}
|
||||
}
|
||||
|
||||
if (process.isJavaProcess() && !jasperreport)
|
||||
|
|
Loading…
Reference in New Issue