fixes bug 37872: Error when directly open a child record whose tab has filters
authorCarlos Aristu <carlos.aristu@openbravo.com>
Tue, 13 Feb 2018 08:43:38 +0100
changeset 33424 af39974bd6a5
parent 33423 83ecad689e9e
child 33425 d6507984d651
fixes bug 37872: Error when directly open a child record whose tab has filters

When direct opening a child record whose tab already has a filter applied (because of a previously created saved view) a JS error was being thrown in the loadFilterAuxiliaryCache function. This was caused because the form of the filter editor was not present yet. To prevent this error, we are now checking whether that form exists before continue with the execution of the loadFilterAuxiliaryCache function.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Mon Feb 12 12:38:32 2018 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Tue Feb 13 08:43:38 2018 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2017 Openbravo SLU
+ * All portions are Copyright (C) 2010-2018 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -1215,7 +1215,7 @@
   // loads the foreign key filter auxiliary cache of all the filter fields that were using the 'id' filter type when the view was saved
   loadFilterAuxiliaryCache: function (filterAuxCache) {
     var i, cacheElement, filterField;
-    if (!filterAuxCache || !isc.isA.Array(filterAuxCache) || filterAuxCache.length === 0) {
+    if (!this.canLoadFilterAuxiliaryCache(filterAuxCache)) {
       return;
     }
     for (i = 0; i < filterAuxCache.length; i++) {
@@ -1228,6 +1228,10 @@
     }
   },
 
+  canLoadFilterAuxiliaryCache: function (filterAuxCache) {
+    return filterAuxCache && isc.isA.Array(filterAuxCache) && filterAuxCache.length > 0 && this.filterEditor && this.filterEditor.getEditForm();
+  },
+
   // overridden to also store the group mode
   // http://forums.smartclient.com/showthread.php?p=93877#post93877
   getGroupState: function () {