From 9441393a77aeb5149f66bee36d0338f438030b75 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 26 Aug 2009 16:46:11 +0000 Subject: [PATCH] Fix [2845052] - InventoryCountUpdate calling wrongly deleteInventoryMA https://sourceforge.net/tracker/?func=detail&aid=2845052&group_id=176962&atid=879332 --- base/src/org/compiere/model/MInventory.java | 2 +- .../src/org/compiere/model/MInventoryLineMA.java | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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"