Search in sources :

Example 1 with MBOMProduct

use of org.compiere.model.MBOMProduct in project adempiere by adempiere.

the class BOMValidate method validateBOM.

//	validateOldProduct
/**
	 * 	Validate BOM
	 *	@param bom bom
	 *	@return true if valid
	 */
private boolean validateBOM(MBOM bom) {
    MBOMProduct[] BOMproducts = MBOMProduct.getOfBOM(bom);
    for (int i = 0; i < BOMproducts.length; i++) {
        MBOMProduct BOMproduct = BOMproducts[i];
        MProduct pp = new MProduct(getCtx(), BOMproduct.getM_BOMProduct_ID(), get_TrxName());
        if (pp.isBOM())
            return validateProduct(pp, bom.getBOMType(), bom.getBOMUse());
    }
    return true;
}
Also used : MProduct(org.compiere.model.MProduct) MBOMProduct(org.compiere.model.MBOMProduct) MBOMProduct(org.compiere.model.MBOMProduct)

Example 2 with MBOMProduct

use of org.compiere.model.MBOMProduct in project adempiere by adempiere.

the class BOMValidate method validateProduct.

//	validateBOM
/**
	 * 	Validate Product
	 *	@param product product
	 *	@param BOMType type
	 *	@param BOMUse use
	 *	@return true if valid
	 */
private boolean validateProduct(MProduct product, String BOMType, String BOMUse) {
    if (!product.isBOM())
        return true;
    //
    String restriction = "BOMType='" + BOMType + "' AND BOMUse='" + BOMUse + "'";
    MBOM[] boms = MBOM.getOfProduct(getCtx(), p_M_Product_ID, get_TrxName(), restriction);
    if (boms.length != 1) {
        log.warning(restriction + " - Length=" + boms.length);
        return false;
    }
    if (m_products.contains(product)) {
        log.warning(m_product.getName() + " recursively includes " + product.getName());
        return false;
    }
    m_products.add(product);
    log.fine(product.getName());
    //
    MBOM bom = boms[0];
    MBOMProduct[] BOMproducts = MBOMProduct.getOfBOM(bom);
    for (int i = 0; i < BOMproducts.length; i++) {
        MBOMProduct BOMproduct = BOMproducts[i];
        MProduct pp = new MProduct(getCtx(), BOMproduct.getM_BOMProduct_ID(), get_TrxName());
        if (pp.isBOM())
            return validateProduct(pp, bom.getBOMType(), bom.getBOMUse());
    }
    return true;
}
Also used : MProduct(org.compiere.model.MProduct) MBOMProduct(org.compiere.model.MBOMProduct) MBOMProduct(org.compiere.model.MBOMProduct) MBOM(org.compiere.model.MBOM)

Aggregations

MBOMProduct (org.compiere.model.MBOMProduct)2 MProduct (org.compiere.model.MProduct)2 MBOM (org.compiere.model.MBOM)1