Fixes issue 30455: Add support for multiple filtering in Stock Reservation P&E
authorMark <markmm82@gmail.com>
Thu, 09 Jun 2016 11:05:00 -0400
changeset 29652 d1bf16311eab
parent 29651 21698df6e4fe
child 29653 bf09b8450ffa
Fixes issue 30455: Add support for multiple filtering in Stock Reservation P&E

Added support for multiple criteria filtering in getGridData method
src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java
--- a/src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java	Thu Jun 16 10:04:13 2016 +0200
+++ b/src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java	Thu Jun 09 11:05:00 2016 -0400
@@ -531,7 +531,20 @@
         if (criteria.has("criteria") && criteria.has("operator")) {
           JSONArray mySon = new JSONArray(criteria.getString("criteria"));
           for (int j = 0; j < mySon.length(); j++) {
-            if (filterCriteria.containsKey(mySon.getJSONObject(j).getString("fieldName"))) {
+            if (mySon.getJSONObject(j).has("criteria") && criteria.has("operator")) {
+              JSONArray mySubSom = new JSONArray(mySon.getJSONObject(j).getString("criteria"));
+              for (int k = 0; k < mySubSom.length(); k++) {
+                if (filterCriteria.containsKey(mySubSom.getJSONObject(k).getString("fieldName"))) {
+                  JSONArray values = new JSONArray(
+                      filterCriteria.get(mySubSom.getJSONObject(k).getString("fieldName")));
+                  filterCriteria.put(mySubSom.getJSONObject(k).getString("fieldName"),
+                      values.put(mySubSom.getJSONObject(k)).toString());
+                } else {
+                  filterCriteria.put(mySubSom.getJSONObject(k).getString("fieldName"),
+                      new JSONArray().put(mySubSom.getJSONObject(k)).toString());
+                }
+              }
+            } else if (filterCriteria.containsKey(mySon.getJSONObject(j).getString("fieldName"))) {
               JSONArray values = new JSONArray(filterCriteria.get(mySon.getJSONObject(j).getString(
                   "fieldName")));
               filterCriteria.put(mySon.getJSONObject(j).getString("fieldName"),