From d4765a29e41d6594abeeb6c6ded42a74c07188a9 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Wed, 13 Sep 2017 15:01:34 +0800 Subject: [PATCH] IDEMPIERE-3361 Cost details inherit amt/qty from wrong history cost element --- .../src/org/compiere/model/MCostDetail.java | 12 ++++++++---- 1 file changed, 8 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 6333bec9ec..5c0f126e4d 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostDetail.java +++ b/org.adempiere.base/src/org/compiere/model/MCostDetail.java @@ -1383,10 +1383,14 @@ public class MCostDetail extends X_M_CostDetail log.warning("Unknown Type: " + toString()); return false; } - setCurrentCostPrice(cost.getCurrentCostPrice()); - setCurrentQty(cost.getCurrentQty()); - setCumulatedAmt(cost.getCumulatedAmt()); - setCumulatedQty(cost.getCumulatedQty()); + + //Should only update cost detail with value from as costing method + if(as.getCostingMethod().equals(ce.getCostingMethod())) { + setCurrentCostPrice(cost.getCurrentCostPrice()); + setCurrentQty(cost.getCurrentQty()); + setCumulatedAmt(cost.getCumulatedAmt()); + setCumulatedQty(cost.getCumulatedQty()); + } //update history history.setNewQty(cost.getCurrentQty());