Fixes issue 35337: Fix CostingUtils.existsProcessedTransactions method
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Thu, 23 Feb 2017 14:19:19 +0100
changeset 31555 ef9c1ff7a9c2
parent 31554 d202b98c89e8
child 31556 a6db92f321b6
Fixes issue 35337: Fix CostingUtils.existsProcessedTransactions method

Add an alias for Locator class in CostingUtils.existsProcessedTransactions method.
src/org/openbravo/costing/CostingUtils.java
--- a/src/org/openbravo/costing/CostingUtils.java	Thu Feb 23 12:49:01 2017 +0100
+++ b/src/org/openbravo/costing/CostingUtils.java	Thu Feb 23 14:19:19 2017 +0100
@@ -794,13 +794,13 @@
 
     OBCriteria<MaterialTransaction> criteria = OBDal.getInstance().createCriteria(
         MaterialTransaction.class);
+    criteria.createAlias(MaterialTransaction.PROPERTY_STORAGEBIN, "sb");
     criteria.add(Restrictions.eq(MaterialTransaction.PROPERTY_PRODUCT, product));
     criteria.add(Restrictions.eq(MaterialTransaction.PROPERTY_ISPROCESSED, true));
     criteria.add(Restrictions.in(MaterialTransaction.PROPERTY_ORGANIZATION + ".id", orgs));
     if (costDimensions.get(CostDimension.Warehouse) != null) {
-      criteria.add(Restrictions
-          .eq(MaterialTransaction.PROPERTY_STORAGEBIN + "." + Locator.PROPERTY_WAREHOUSE + ".id",
-              costDimensions.get(CostDimension.Warehouse).getId()));
+      criteria.add(Restrictions.eq("sb." + Locator.PROPERTY_WAREHOUSE + ".id",
+          costDimensions.get(CostDimension.Warehouse).getId()));
     }
     criteria.setFilterOnReadableOrganization(false);
     criteria.setMaxResults(1);