BF [ 2543448 ] CompletePrintOrder: Manufacturing Order Workflow not found
https://sourceforge.net/tracker/index.php?func=detail&aid=2543448&group_id=176962&atid=879332
This commit is contained in:
parent
f1700d17e1
commit
e9166ff96a
|
@ -12,6 +12,7 @@
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Teo Sarca, www.arhipac.ro *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.process;
|
package org.eevolution.process;
|
||||||
|
|
||||||
|
@ -22,23 +23,25 @@ import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.exceptions.FillMandatoryException;
|
import org.adempiere.exceptions.FillMandatoryException;
|
||||||
import org.compiere.model.MQuery;
|
import org.compiere.model.MQuery;
|
||||||
import org.compiere.model.PrintInfo;
|
import org.compiere.model.PrintInfo;
|
||||||
|
import org.compiere.model.Query;
|
||||||
import org.compiere.print.MPrintFormat;
|
import org.compiere.print.MPrintFormat;
|
||||||
import org.compiere.print.ReportCtl;
|
import org.compiere.print.ReportCtl;
|
||||||
import org.compiere.print.ReportEngine;
|
import org.compiere.print.ReportEngine;
|
||||||
|
import org.compiere.process.ClientProcess;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
import org.compiere.process.SvrProcess;
|
import org.compiere.process.SvrProcess;
|
||||||
import org.compiere.util.Env;
|
|
||||||
import org.compiere.util.Language;
|
import org.compiere.util.Language;
|
||||||
import org.compiere.util.Msg;
|
|
||||||
import org.eevolution.model.MPPOrder;
|
import org.eevolution.model.MPPOrder;
|
||||||
|
import org.eevolution.model.MPPOrderWorkflow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CompletePrintOrder
|
* Complete & Print Manufacturing Order
|
||||||
*
|
|
||||||
* @author victor.perez@e-evolution.com
|
* @author victor.perez@e-evolution.com
|
||||||
* @version $Id: CompletePrintOrder.java,v 1.4 2004/05/07 05:52:14 vpj-cd Exp $
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class CompletePrintOrder extends SvrProcess {
|
public class CompletePrintOrder extends SvrProcess
|
||||||
|
implements ClientProcess
|
||||||
|
{
|
||||||
/** The Order */
|
/** The Order */
|
||||||
private int p_PP_Order_ID = 0;
|
private int p_PP_Order_ID = 0;
|
||||||
private boolean p_IsPrintPickList = false;
|
private boolean p_IsPrintPickList = false;
|
||||||
|
@ -50,22 +53,23 @@ public class CompletePrintOrder extends SvrProcess {
|
||||||
/**
|
/**
|
||||||
* Prepare - e.g., get Parameters.
|
* Prepare - e.g., get Parameters.
|
||||||
*/
|
*/
|
||||||
protected void prepare() {
|
protected void prepare()
|
||||||
ProcessInfoParameter[] para = getParameter();
|
{
|
||||||
for (int i = 0; i < para.length; i++) {
|
for (ProcessInfoParameter para : getParameter())
|
||||||
String name = para[i].getParameterName();
|
{
|
||||||
if (para[i].getParameter() == null)
|
String name = para.getParameterName();
|
||||||
|
if (para.getParameter() == null)
|
||||||
;
|
;
|
||||||
else if (name.equals("PP_Order_ID"))
|
else if (name.equals("PP_Order_ID"))
|
||||||
p_PP_Order_ID = para[i].getParameterAsInt();
|
p_PP_Order_ID = para.getParameterAsInt();
|
||||||
else if (name.equals("IsPrintPickList"))
|
else if (name.equals("IsPrintPickList"))
|
||||||
p_IsPrintPickList = "Y".equals(para[i].getParameter());
|
p_IsPrintPickList = para.getParameterAsBoolean();
|
||||||
else if (name.equals("IsPrintWorkflow"))
|
else if (name.equals("IsPrintWorkflow"))
|
||||||
p_IsPrintWorkflow = "Y".equals(para[i].getParameter());
|
p_IsPrintWorkflow = para.getParameterAsBoolean();
|
||||||
else if (name.equals("IsPrintPackingList"))
|
else if (name.equals("IsPrintPackingList"))
|
||||||
p_IsPrintPackList = "Y".equals(para[i].getParameter());
|
p_IsPrintPackList = para.getParameterAsBoolean();
|
||||||
else if (name.equals("IsComplete"))
|
else if (name.equals("IsComplete"))
|
||||||
p_IsComplete = "Y".equals(para[i].getParameter());
|
p_IsComplete = para.getParameterAsBoolean();
|
||||||
else
|
else
|
||||||
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
|
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +84,6 @@ public class CompletePrintOrder extends SvrProcess {
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws Exception
|
protected String doIt() throws Exception
|
||||||
{
|
{
|
||||||
Language language = Language.getLoginLanguage(); // Base Language
|
|
||||||
|
|
||||||
if (p_PP_Order_ID == 0)
|
if (p_PP_Order_ID == 0)
|
||||||
{
|
{
|
||||||
|
@ -90,22 +93,24 @@ public class CompletePrintOrder extends SvrProcess {
|
||||||
if (p_IsComplete)
|
if (p_IsComplete)
|
||||||
{
|
{
|
||||||
MPPOrder order = new MPPOrder(getCtx(), p_PP_Order_ID, get_TrxName());
|
MPPOrder order = new MPPOrder(getCtx(), p_PP_Order_ID, get_TrxName());
|
||||||
|
if (!order.isAvailable())
|
||||||
if (order.isAvailable())
|
|
||||||
{
|
{
|
||||||
String status = order.completeIt();
|
throw new AdempiereException("@NoQtyAvailable@");
|
||||||
order.setDocStatus(status);
|
|
||||||
order.saveEx();
|
|
||||||
if (!MPPOrder.DOCSTATUS_Completed.equals(status))
|
|
||||||
{
|
|
||||||
throw new AdempiereException(order.getProcessMsg());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
//
|
||||||
|
// Process document
|
||||||
|
boolean ok = order.processIt(MPPOrder.DOCSTATUS_Completed);
|
||||||
|
order.saveEx();
|
||||||
|
if (!ok)
|
||||||
{
|
{
|
||||||
return Msg.translate(Env.getCtx(), "NoQtyAvailable");
|
throw new AdempiereException(order.getProcessMsg());
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Document Status should be completed
|
||||||
|
if (!MPPOrder.DOCSTATUS_Completed.equals(order.getDocStatus()))
|
||||||
|
{
|
||||||
|
throw new AdempiereException(order.getProcessMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_IsPrintPickList)
|
if (p_IsPrintPickList)
|
||||||
|
@ -117,18 +122,16 @@ public class CompletePrintOrder extends SvrProcess {
|
||||||
}
|
}
|
||||||
if (p_IsPrintWorkflow)
|
if (p_IsPrintWorkflow)
|
||||||
{
|
{
|
||||||
// Get Format & Data
|
MPrintFormat format = getAD_PrintFormat(MPPOrderWorkflow.Table_ID);
|
||||||
MPrintFormat format = MPrintFormat.get(getCtx(), MPrintFormat.getPrintFormat_ID(
|
if (format == null)
|
||||||
"Manufacturing Order Workflow", MPPOrder.Table_ID, getAD_Client_ID()),
|
{
|
||||||
false);
|
addLog("@NotFound@ @AD_PrintFormat_ID@ @PP_Order_Workflow_ID@");
|
||||||
|
}
|
||||||
format.setLanguage(language);
|
|
||||||
format.setTranslationLanguage(language);
|
|
||||||
// query
|
// query
|
||||||
MQuery query = new MQuery(MPPOrder.Table_Name);
|
MQuery query = new MQuery(MPPOrderWorkflow.Table_Name);
|
||||||
query.addRestriction(MPPOrder.COLUMNNAME_PP_Order_ID, MQuery.EQUAL, p_PP_Order_ID);
|
query.addRestriction(MPPOrderWorkflow.COLUMNNAME_PP_Order_ID, MQuery.EQUAL, p_PP_Order_ID);
|
||||||
// Engine
|
// Engine
|
||||||
PrintInfo info = new PrintInfo("PP_Order", MPPOrder.Table_ID, p_PP_Order_ID);
|
PrintInfo info = new PrintInfo(MPPOrderWorkflow.Table_Name, MPPOrderWorkflow.Table_ID, p_PP_Order_ID);
|
||||||
ReportEngine re = new ReportEngine(getCtx(), format, query, info);
|
ReportEngine re = new ReportEngine(getCtx(), format, query, info);
|
||||||
ReportCtl.preview(re);
|
ReportCtl.preview(re);
|
||||||
re.print(); // prints only original
|
re.print(); // prints only original
|
||||||
|
@ -138,4 +141,21 @@ public class CompletePrintOrder extends SvrProcess {
|
||||||
|
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
|
private MPrintFormat getAD_PrintFormat(int AD_Table_ID)
|
||||||
|
{
|
||||||
|
final String whereClause = MPrintFormat.COLUMNNAME_AD_Table_ID+"=?"
|
||||||
|
+" AND AD_Client_ID IN (0,?)";
|
||||||
|
MPrintFormat format = new Query(getCtx(), MPrintFormat.Table_Name, whereClause, null)
|
||||||
|
.setParameters(new Object[]{AD_Table_ID, getAD_Client_ID()})
|
||||||
|
.setOrderBy("IsDefault DESC, AD_Client_ID DESC")
|
||||||
|
.first();
|
||||||
|
if (format == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Language language = Language.getLoginLanguage(); // Base Language
|
||||||
|
format.setLanguage(language);
|
||||||
|
format.setTranslationLanguage(language);
|
||||||
|
return format;
|
||||||
|
}
|
||||||
} // CompletePrintOrder
|
} // CompletePrintOrder
|
||||||
|
|
Loading…
Reference in New Issue