Fixes issue 30274: uuid appear in saved views with multiple criteria on a field
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 02 Jul 2015 09:40:16 +0200
changeset 27100 b685cad82eef
parent 27099 80e3d00ad42c
child 27101 d759928f7271
child 27150 c663dfeb30dc
Fixes issue 30274: uuid appear in saved views with multiple criteria on a field

When a view is saved while any of its filters are currently using the 'id' filter type, the id and identifier of the selected options are stored in a cache. If we have multiple criteria on one field, an internal loop is executed to retrieve all the criterias in the getFKFilterAuxiliaryCache function.

The problem was that this internal loop was using the same variable as the external one to insert those criterias into the cache. This caused that the subsequent filters for next fields were not being handled properly as the condition of the external loop was not being fulfilled anymore due to the increment done in the internal loop.

This has been solved just using a new variable 'j' in the internal loop.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Tue Jun 30 18:43:16 2015 +0000
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Thu Jul 02 09:40:16 2015 +0200
@@ -868,7 +868,7 @@
     var filterField, criterion, filterLength = criteria.criteria.length,
         fkFilterAuxCache = [],
         innerCache = [],
-        filterEditForm, cacheElement, i;
+        filterEditForm, cacheElement, i, j;
     if (!this.filterEditor || !this.filterEditor.getEditForm()) {
       return fkFilterAuxCache;
     }
@@ -879,11 +879,11 @@
       innerCache = [];
       if (filterField && filterField.filterType === 'id') {
         if (criterion.criteria) {
-          for (i = 0; i < criterion.criteria.length; i++) {
+          for (j = 0; j < criterion.criteria.length; j++) {
             cacheElement = {};
-            cacheElement.fieldName = criterion.criteria[i].fieldName;
-            cacheElement[OB.Constants.ID] = criterion.criteria[i].value;
-            cacheElement[OB.Constants.IDENTIFIER] = filterField.getRecordIdentifierFromId(criterion.criteria[i].value);
+            cacheElement.fieldName = criterion.criteria[j].fieldName;
+            cacheElement[OB.Constants.ID] = criterion.criteria[j].value;
+            cacheElement[OB.Constants.IDENTIFIER] = filterField.getRecordIdentifierFromId(criterion.criteria[j].value);
             innerCache.add(cacheElement);
           }
         } else {