From 4d36e46a6e40b58ac007c22de8a8816d072cc066 Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Tue, 30 Dec 2008 23:31:35 +0000 Subject: [PATCH] http://sourceforge.net/tracker2/index.php?func=detail&aid=2282037&group_id=176962&atid=879335 Autoproduce product for shipment --- base/src/org/eevolution/model/MPPMRP.java | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/base/src/org/eevolution/model/MPPMRP.java b/base/src/org/eevolution/model/MPPMRP.java index 6e19632dc2..4b08980f4c 100644 --- a/base/src/org/eevolution/model/MPPMRP.java +++ b/base/src/org/eevolution/model/MPPMRP.java @@ -266,12 +266,40 @@ public class MPPMRP extends X_PP_MRP MPPProductBOM bom = new Query(ctx, MPPProductBOM.Table_Name, where, trxName) .setParameters(new Object[]{MPPProductBOM.BOMTYPE_Make_To_Order, ol.getM_Product_ID()}) .first(); + + MPPProductPlanning pp = null; + //Validate the BOM based in planning data + if(bom == null) + { + pp = MPPProductPlanning.find( ctx, ol.getAD_Org_ID() , 0, 0, ol.getM_Product_ID(), trxName); + if(pp != null) + { + if(pp.getPP_Product_BOM_ID() != 0) + { + bom = (MPPProductBOM) pp.getPP_Product_BOM(); + if(!bom.getBOMType().equals(MPPProductBOM.BOMTYPE_Make_To_Order)) + bom = null; + } + } + } + if (bom != null) { MProduct product = MProduct.get(ctx,ol.getM_Product_ID()); String WhereClause = "ManufacturingResourceType = 'PT' AND IsManufacturingResource = 'Y' AND AD_Client_ID = ? AND M_Warehouse_ID = ?"; MResource m_resource = (MResource)MTable.get(ctx,MResource.Table_ID).getPO(WhereClause, new Object[]{ ol.getAD_Client_ID(),ol.getM_Warehouse_ID()}, trxName); + MWorkflow m_workflow = MWorkflow.get(ctx, MWorkflow.getWorkflowSearchKey(ctx, product)); + + //Validate the workflow based in planning data + if(m_workflow == null) + { + if(pp != null && pp.getAD_Workflow_ID() != 0) + { + m_workflow = (MWorkflow) pp.getAD_Workflow(); + } + } + if (m_resource != null && m_workflow != null) { MDocType[] doc = MDocType.getOfDocBaseType(ctx, X_C_DocType.DOCBASETYPE_ManufacturingOrder);