* packed product is not verified; The attribute set instance of the
* pack does not have an SG value.
*/
protected String doIt() throws Exception
{
X_Z_Packs pack = new X_Z_Packs(getCtx(), getRecord_ID(), get_TrxName());
MProduct product = new MProduct(getCtx(), pack.getM_Product_ID(), get_TrxName());
MPPProductBOM bom = MPPProductBOM.get(product, getAD_Client_ID(), get_TrxName());
MLocator loc = new MLocator(getCtx(), p_M_Locator_ID, get_TrxName());
int chargeID = getChargeID();
// Error Checking. An error results in an exception thrown which is caught
// by SrvProcess which then rolls back any changes to the database made as
// part of the get_TrxName() transaction.
if (bom.is_new())
throw new AdempiereUserError("@Error@ Bill Of Materials does not exist for "+
product.getName());
if (product.getVolume() == null || product.getVolume().doubleValue() <= 0)
throw new AdempiereUserError("@Error@ Volume value for product "+product.getName()+
" is zero or less.");
if (!product.isVerified())
throw new AdempiereUserError("@Error@ Product "+product.getName()+" is not verified");
// Create the Inventory record
MInventory inv = new MInventory(getCtx(), 0, get_TrxName());
inv.setM_Warehouse_ID(loc.getM_Warehouse_ID());
inv.setClientOrg(getAD_Client_ID(), Env.getAD_Org_ID(getCtx()));
inv.addDescription("From BOM " + bom.getValue());
inv.setZPacksDocumentNo();
inv.save(get_TrxName());
// Add the packed product inventory line and then copy lines from the BOM
addPackedProductLine(pack, product, inv, chargeID);
copyBOMLines(bom, pack, product, inv, chargeID);
// Assign the new inventory to the pack
pack.setM_Inventory_ID(inv.getM_Inventory_ID());
pack.save(get_TrxName());
// Return the message to be shown in the status bar. The SrvProcess will
// commit all changes to the database made as part of the get_TrxName()
// transaction.
return "Physical Inventory "+inv.getDocumentNo()+" created.";