Process Problem being called by ValidatorOrder

Help is preferred to those who publish their work as Open Source and not as private branches rejecting collaboration. Such projects are not maintainable and shall be deleted.
Forum rules
This forum is personally pruned to avoid redundant posts. Related topics are grouped together. IF YOU HAVE REGISTERED, you need to send email to red1(a)red1.org with your username in the subject title to get me to activate you.

Process Problem being called by ValidatorOrder

Postby edilsondneto » Wed Mar 19, 2014 12:57 am

Hello Anyone,

I'm a problem in the validator c_order, I call a process to convert a proposal/quote in a sales order. When I call this process the order still in transaction, and I think it causes an infinite loop. Anyone have any idea what should I do?





public class ValidatorOrder implements ModelValidator

......

if (timing == TIMING_BEFORE_COMPLETE ){
processQuoteCopy(order, doctype);

}


/**
* Method Process C_Order QuoteCopy
* @param pi ProcessInfo
*/
public static boolean processQuoteCopy(MOrder order, MDocType dt) {

// need to commit in order to allow jasper to view the data
Trx trx = Trx.get(order.get_TableName(), true);
trx.commit();

Timestamp dateCurrent = (new Timestamp(System.currentTimeMillis()));

// Create instance parameters. I e the parameters you want to send to the process.
ProcessInfoParameter pi1 = new ProcessInfoParameter("C_Order_ID", (BigDecimal.valueOf(order.getC_Order_ID())), "","","");
// ProcessInfoParameter pi2 = new ProcessInfoParameter("C_DocType_ID", (BigDecimal.valueOf(dt.getlcr_DocTypeSO_ID())), "","","");
ProcessInfoParameter pi2 = new ProcessInfoParameter("C_DocType_ID",
(BigDecimal.valueOf(MSysConfig.getIntValue("LCR_ALWAYS_CONVERT_QUOTE_AUTOMATIC_DOCTYPE", 0))), "", "", "");
ProcessInfoParameter pi3 = new ProcessInfoParameter("DateDoc", dateCurrent, "","","");
ProcessInfoParameter pi4 = new ProcessInfoParameter("IsCloseDocument", true, "","","");

// Create a process info instance. This is a composite class containing the parameters.
ProcessInfo pi = new ProcessInfo("", 0,0,0);
pi.setParameter(new ProcessInfoParameter[] {pi1, pi2, pi3, pi4});

// Lookup process in the AD, in this case by value
MProcess pr = new Query(Env.getCtx(), MProcess.Table_Name, "value=?", null)
.setParameters(new Object[]{"QuoteCopy"})
.first();
if (pr==null) {
//log.warning("This process " + pr.getName() + " not exists. ");
return false;
}


// Create an instance of the actual process class.
CopyOrder process = new CopyOrder();

// Create process instance (mainly for logging/sync purpose)
MPInstance mpi = new MPInstance(Env.getCtx(), 0, null);
mpi.setAD_Process_ID(pr.get_ID());
mpi.setRecord_ID(0);
mpi.save();

// Connect the process to the process instance.
pi.setAD_PInstance_ID(mpi.get_ID());

//log.info("Iniciando processo " + pr.getName());
boolean result = process.startProcess(order.getCtx(), pi, trx);
return result;

}
edilsondneto
 
Posts: 16
Joined: Wed Aug 17, 2011 8:22 pm

Return to HELP ME!!!

Who is online

Users browsing this forum: No registered users and 2 guests

cron