It doesn't get the right UOM into the Manufacturing Order

http://sourceforge.net/tracker2/?func=detail&atid=879332&aid=2530090&group_id=176962

Fix the Default UOM, refactory method do not is necessary send the context this can be take of Product instance.
This commit is contained in:
vpj-cd 2009-01-27 08:14:05 +00:00
parent 65e84ad825
commit 3855061d34
8 changed files with 20 additions and 15 deletions

View File

@ -940,9 +940,9 @@ public class MWorkflow extends X_AD_Workflow
* @param M_Product_ID * @param M_Product_ID
* @return AD_Workflow_ID * @return AD_Workflow_ID
*/ */
public static int getWorkflowSearchKey(Properties ctx, MProduct product) public static int getWorkflowSearchKey(MProduct product)
{ {
int AD_Client_ID = Env.getAD_Client_ID(ctx); int AD_Client_ID = Env.getAD_Client_ID(product.getCtx());
String sql = "SELECT AD_Workflow_ID FROM AD_Workflow " String sql = "SELECT AD_Workflow_ID FROM AD_Workflow "
+" WHERE Value = ? AND AD_Client_ID = ?"; +" WHERE Value = ? AND AD_Client_ID = ?";
return DB.getSQLValue(null, sql, product.getValue(), AD_Client_ID); return DB.getSQLValue(null, sql, product.getValue(), AD_Client_ID);

View File

@ -55,12 +55,11 @@ public class CalloutOrder extends CalloutEngine
{ {
if (value == null) if (value == null)
return ""; return "";
//setCalloutActive(true);
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID"); int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
if (steps) log.warning("qty - init - M_Product_ID=" + M_Product_ID + " - " ); if (steps) log.warning("qty - init - M_Product_ID=" + M_Product_ID + " - " );
BigDecimal QtyOrdered = Env.ZERO ; BigDecimal QtyOrdered = Env.ZERO ;
BigDecimal QtyEntered = Env.ZERO ; //, PriceActual, PriceEntered; BigDecimal QtyEntered = Env.ZERO ;
// No Product // No Product
if (M_Product_ID == 0) if (M_Product_ID == 0)
@ -154,12 +153,17 @@ public class CalloutOrder extends CalloutEngine
MProduct product = MProduct.get(ctx, ((Number)value).intValue()); MProduct product = MProduct.get(ctx, ((Number)value).intValue());
if (product == null) if (product == null)
return ""; return "";
mTab.setValue(MProduct.COLUMNNAME_C_UOM_ID,product.getC_UOM_ID());
int workflow_id = MWorkflow.getWorkflowSearchKey(ctx, product); int workflow_id = MWorkflow.getWorkflowSearchKey(product);
mTab.setValue(MPPOrder.COLUMNNAME_AD_Workflow_ID, workflow_id > 0 ? workflow_id : null); mTab.setValue(MPPOrder.COLUMNNAME_AD_Workflow_ID, workflow_id > 0 ? workflow_id : null);
int bom_id = MPPProductBOM.getBOMSearchKey(ctx, product); MPPProductBOM bom = MPPProductBOM.getDefault(product, null);
mTab.setValue(MPPOrder.COLUMNNAME_PP_Product_BOM_ID, bom_id > 0 ? bom_id : null); if (bom == null)
return "";
mTab.setValue(MPPOrder.COLUMNNAME_PP_Product_BOM_ID, bom.get_ID());
mTab.setValue(MPPOrder.COLUMNNAME_C_UOM_ID,bom.getC_UOM_ID());
return ""; return "";
} }

View File

@ -406,7 +406,7 @@ public class MPPMRP extends X_PP_MRP
//TODO: vpj-cd create the msg for error //TODO: vpj-cd create the msg for error
throw new AdempiereException("Do not exist Resource Plant for this Warehouse"); throw new AdempiereException("Do not exist Resource Plant for this Warehouse");
} }
MWorkflow workflow = MWorkflow.get(ol.getCtx(), MWorkflow.getWorkflowSearchKey(ol.getCtx(), product)); MWorkflow workflow = MWorkflow.get(ol.getCtx(), MWorkflow.getWorkflowSearchKey(product));
//Validate the workflow based in planning data //Validate the workflow based in planning data
if(workflow == null && pp != null) if(workflow == null && pp != null)
{ {

View File

@ -155,7 +155,7 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
if(m_qtyToExplode != null) if(m_qtyToExplode != null)
{ {
MProduct parent = MProduct.get(getCtx(), getM_Product_ID()); MProduct parent = MProduct.get(getCtx(), getM_Product_ID());
int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(getCtx(), parent); int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(parent);
if (PP_Product_BOM_ID <= 0) if (PP_Product_BOM_ID <= 0)
{ {
return true; return true;

View File

@ -73,9 +73,9 @@ public class MPPProductBOM extends X_PP_Product_BOM
* @param M_Product_ID * @param M_Product_ID
* @return PP_Product_BOM_ID * @return PP_Product_BOM_ID
*/ */
public static int getBOMSearchKey(Properties ctx, MProduct product) public static int getBOMSearchKey(MProduct product)
{ {
int AD_Client_ID = Env.getAD_Client_ID(ctx); int AD_Client_ID = Env.getAD_Client_ID(product.getCtx());
String sql = "SELECT PP_Product_BOM_ID FROM PP_Product_BOM" String sql = "SELECT PP_Product_BOM_ID FROM PP_Product_BOM"
+" WHERE Value=? AND M_Product_ID=? AND AD_Client_ID=?"; +" WHERE Value=? AND M_Product_ID=? AND AD_Client_ID=?";
return DB.getSQLValueEx(null, sql, product.getValue(), product.get_ID(), AD_Client_ID); return DB.getSQLValueEx(null, sql, product.getValue(), product.get_ID(), AD_Client_ID);
@ -91,6 +91,7 @@ public class MPPProductBOM extends X_PP_Product_BOM
{ {
return new Query(product.getCtx(), Table_Name, "M_Product_ID=? AND Value=?", trxName) return new Query(product.getCtx(), Table_Name, "M_Product_ID=? AND Value=?", trxName)
.setParameters(new Object[]{product.getM_Product_ID(), product.getValue()}) .setParameters(new Object[]{product.getM_Product_ID(), product.getValue()})
.setClient_ID()
.first(); .first();
} }

View File

@ -527,11 +527,11 @@ public class MRP extends SvrProcess
//Find the BOM to this Product //Find the BOM to this Product
if (m_product_planning.getPP_Product_BOM_ID() <= 0 && product.isBOM()) if (m_product_planning.getPP_Product_BOM_ID() <= 0 && product.isBOM())
{ {
m_product_planning.setPP_Product_BOM_ID(MPPProductBOM.getBOMSearchKey(getCtx(), product)); m_product_planning.setPP_Product_BOM_ID(MPPProductBOM.getBOMSearchKey(product));
} }
if (m_product_planning.getAD_Workflow_ID() <= 0 && product.isBOM()) if (m_product_planning.getAD_Workflow_ID() <= 0 && product.isBOM())
{ {
m_product_planning.setAD_Workflow_ID(MWorkflow.getWorkflowSearchKey(getCtx(), product)); m_product_planning.setAD_Workflow_ID(MWorkflow.getWorkflowSearchKey(product));
} }
if (m_product_planning.getPlanner_ID() <= 0) if (m_product_planning.getPlanner_ID() <= 0)
{ {

View File

@ -184,7 +184,7 @@ public class RollupBillOfMaterial extends SvrProcess
} }
if (PP_Product_BOM_ID <= 0) if (PP_Product_BOM_ID <= 0)
{ {
PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(getCtx(), product); PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(product);
} }
if (PP_Product_BOM_ID <= 0) if (PP_Product_BOM_ID <= 0)
{ {

View File

@ -138,7 +138,7 @@ public class RollupWorkflow extends SvrProcess
} }
if (AD_Workflow_ID <= 0) if (AD_Workflow_ID <= 0)
{ {
AD_Workflow_ID = MWorkflow.getWorkflowSearchKey(getCtx(), product); AD_Workflow_ID = MWorkflow.getWorkflowSearchKey(product);
} }
if(AD_Workflow_ID <= 0) if(AD_Workflow_ID <= 0)
{ {