diff --git a/base/src/org/compiere/model/MInventory.java b/base/src/org/compiere/model/MInventory.java index 3335cdde6c..5a17a389c9 100644 --- a/base/src/org/compiere/model/MInventory.java +++ b/base/src/org/compiere/model/MInventory.java @@ -570,7 +570,7 @@ public class MInventory extends X_M_Inventory implements DocAction */ private void checkMaterialPolicy(MInventoryLine line, BigDecimal qtyDiff) { - int no = MInventoryLineMA.deleteInventoryMA(line.getM_InventoryLine_ID(), get_TrxName()); + int no = MInventoryLineMA.deleteInventoryLineMA(line.getM_InventoryLine_ID(), get_TrxName()); if (no > 0) log.config("Delete old #" + no); diff --git a/base/src/org/compiere/model/MInventoryLineMA.java b/base/src/org/compiere/model/MInventoryLineMA.java index 94c7e3c19f..4a133c6391 100644 --- a/base/src/org/compiere/model/MInventoryLineMA.java +++ b/base/src/org/compiere/model/MInventoryLineMA.java @@ -83,7 +83,21 @@ public class MInventoryLineMA extends X_M_InventoryLineMA * @param trxName transaction * @return number of rows deleted or -1 for error */ - public static int deleteInventoryMA (int M_InventoryLine_ID, String trxName) + public static int deleteInventoryMA (int M_Inventory_ID, String trxName) + { + String sql = "DELETE FROM M_InventoryLineMA ma WHERE EXISTS " + + "(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID" + + " AND M_Inventory_ID=" + M_Inventory_ID + ")"; + return DB.executeUpdate(sql, trxName); + } // deleteInventoryMA + + /** + * Delete all Material Allocation for Inventory + * @param M_InventoryLine_ID inventory + * @param trxName transaction + * @return number of rows deleted or -1 for error + */ + public static int deleteInventoryLineMA (int M_InventoryLine_ID, String trxName) { String sql = "DELETE FROM M_InventoryLineMA ma WHERE EXISTS " + "(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID"