Fixes issue 21408: When a Product is set as Production, it's
authorDavid Miguelez <david.miguelez@openbravo.com>
Thu, 13 Sep 2012 12:53:17 +0200
changeset 17937 af015ec644dd
parent 17936 3292566b5a1b
child 17938 a8cb5918bad6
Fixes issue 21408: When a Product is set as Production, it's
entries in M_Costing will have * as Organization.
src/org/openbravo/costing/AverageAlgorithm.java
--- a/src/org/openbravo/costing/AverageAlgorithm.java	Tue Sep 11 12:02:07 2012 +0200
+++ b/src/org/openbravo/costing/AverageAlgorithm.java	Thu Sep 13 12:53:17 2012 +0200
@@ -32,6 +32,7 @@
 import org.openbravo.dal.service.OBQuery;
 import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.financial.FinancialUtils;
+import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.enterprise.Warehouse;
 import org.openbravo.model.common.plm.Product;
 import org.openbravo.model.materialmgmt.cost.Costing;
@@ -131,7 +132,11 @@
     cost.setEndingDate(dateTo);
     cost.setInventoryTransaction(transaction);
     cost.setProduct(transaction.getProduct());
-    cost.setOrganization(costOrg);
+    if (transaction.getProduct().isProduction()) {
+      cost.setOrganization(OBDal.getInstance().get(Organization.class, "0"));
+    } else {
+      cost.setOrganization(costOrg);
+    }
     cost.setQuantity(transaction.getMovementQuantity());
     cost.setTotalMovementQuantity(currentStock.add(transaction.getMovementQuantity()));
     if (transaction.getMovementQuantity().signum() == 0) {