From f4969a172f117750a2f8a614f5da008941d05ddb Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 4 Jul 2017 20:04:16 +0800 Subject: [PATCH] IDEMPIERE-3352 Enhancement of Batch Level Costing. Use safer approach for production reversal checking. --- .../src/org/compiere/model/MCostDetail.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MCostDetail.java b/org.adempiere.base/src/org/compiere/model/MCostDetail.java index 08bc01703a..4cc2aa662c 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostDetail.java +++ b/org.adempiere.base/src/org/compiere/model/MCostDetail.java @@ -1263,11 +1263,11 @@ public class MCostDetail extends X_M_CostDetail } else if (addition) { - MProductionLine productionLine = (MProductionLine) getM_ProductionLine(); - if (productionLine.getProductionReversalId() <= 0) - cost.add(amt, qty); + MProductionLine productionLine = getM_ProductionLine_ID() > 0 ? new MProductionLine(getCtx(), getM_ProductionLine_ID(), get_TrxName()) : null; + if (productionLine != null && productionLine.getProductionReversalId() > 0) + cost.setCurrentQty(cost.getCurrentQty().add(qty)); else - cost.setCurrentQty(cost.getCurrentQty().add(qty)); + cost.add(amt, qty); // Initial if (cost.getCurrentCostPrice().signum() == 0