From f866eef6b748d8b1f89e58f0602714cbee80c6b1 Mon Sep 17 00:00:00 2001 From: deathmeat Date: Tue, 6 Mar 2007 11:14:52 +0000 Subject: [PATCH] [ 1674225 ] Delete Product: Costing deletion error --- base/src/org/compiere/model/MProduct.java | 117 +++++++++++++--------- 1 file changed, 71 insertions(+), 46 deletions(-) diff --git a/base/src/org/compiere/model/MProduct.java b/base/src/org/compiere/model/MProduct.java index fdd79a2289..bca1678b08 100644 --- a/base/src/org/compiere/model/MProduct.java +++ b/base/src/org/compiere/model/MProduct.java @@ -1,8 +1,8 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * * by the Free Software Foundation. This program is distributed in the hope * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * @@ -99,12 +99,12 @@ public class MProduct extends X_M_Product * @param ctx context * @param M_Product_ID id * @return true if found and stocked - false otherwise - */ - public static boolean isProductStocked (Properties ctx, int M_Product_ID) - { - MProduct product = get (ctx, M_Product_ID); - return product.isStocked(); - } // isProductStocked + */ + public static boolean isProductStocked (Properties ctx, int M_Product_ID) + { + MProduct product = get (ctx, M_Product_ID); + return product.isStocked(); + } // isProductStocked /** Cache */ private static CCache s_cache = new CCache("M_Product", 40, 5); // 5 minutes @@ -160,25 +160,25 @@ public class MProduct extends X_M_Product * Parent Constructor * @param et parent */ - public MProduct (MExpenseType et) - { - this (et.getCtx(), 0, et.get_TrxName()); - setProductType(X_M_Product.PRODUCTTYPE_ExpenseType); - setExpenseType(et); - } // MProduct - + public MProduct (MExpenseType et) + { + this (et.getCtx(), 0, et.get_TrxName()); + setProductType(X_M_Product.PRODUCTTYPE_ExpenseType); + setExpenseType(et); + } // MProduct + /** * Parent Constructor * @param resource parent * @param resourceType resource type */ - public MProduct (MResource resource, MResourceType resourceType) - { - this (resource.getCtx(), 0, resource.get_TrxName()); - setProductType(X_M_Product.PRODUCTTYPE_Resource); - setResource(resource); - setResource(resourceType); - } // MProduct + public MProduct (MResource resource, MResourceType resourceType) + { + this (resource.getCtx(), 0, resource.get_TrxName()); + setProductType(X_M_Product.PRODUCTTYPE_Resource); + setResource(resource); + setResource(resourceType); + } // MProduct /** * Import Constructor @@ -610,25 +610,25 @@ public class MProduct extends X_M_Product // New - Acct, Tree, Old Costing if (newRecord) - { - insert_Accounting("M_Product_Acct", "M_Product_Category_Acct", - "p.M_Product_Category_ID=" + getM_Product_Category_ID()); - insert_Tree(X_AD_Tree.TREETYPE_Product); - // - MAcctSchema[] mass = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID(), get_TrxName()); - for (int i = 0; i < mass.length; i++) + { + insert_Accounting("M_Product_Acct", "M_Product_Category_Acct", + "p.M_Product_Category_ID=" + getM_Product_Category_ID()); + insert_Tree(X_AD_Tree.TREETYPE_Product); + // + MAcctSchema[] mass = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID(), get_TrxName()); + for (int i = 0; i < mass.length; i++) { // Old MProductCosting pcOld = new MProductCosting(this, mass[i].getC_AcctSchema_ID()); pcOld.save(); } - } - - // New Costing - if (newRecord || is_ValueChanged("M_Product_Category_ID")) - MCost.create(this); - - return success; + } + + // New Costing + if (newRecord || is_ValueChanged("M_Product_Category_ID")) + MCost.create(this); + + return success; } // afterSave /** @@ -668,6 +668,31 @@ public class MProduct extends X_M_Product MProductCosting[] costings = MProductCosting.getOfProduct(getCtx(), get_ID(), get_TrxName()); for (int i = 0; i < costings.length; i++) costings[i].delete(true, get_TrxName()); + + // [ 1674225 ] Delete Product: Costing deletion error + MAcctSchema[] mass = MAcctSchema.getClientAcctSchema(getCtx(), + getAD_Client_ID(), get_TrxName()); + for(int i=0; i