Fixed issue 26356:window without a parent key, the tab data is not displayed
authorGuillermo Gil <guillermo.gil@openbravo.com>
Fri, 25 Apr 2014 09:55:56 +0200
changeset 22912 435ecd823209
parent 22911 80312633cde3
child 22913 b856094303a9
Fixed issue 26356:window without a parent key, the tab data is not displayed

False criterion is now removed if the child tab has no parent key.
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	Thu Apr 24 11:52:35 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Apr 25 09:55:56 2014 +0200
@@ -1914,7 +1914,27 @@
           shouldRemove = true;
         } else if (isc.isA.emptyString(criterion.value)) {
           shouldRemove = true;
+        } else if (this.view.parentView && !this.view.parentProperty) {
+          // subtabs without an explicit reference to their parent property need to remove unused criterias
+          if (this.view.parentView.isShowingTree) {
+            selectedValues = this.view.parentView.treeGrid.getSelectedRecords();
+          } else {
+            selectedValues = this.view.parentView.viewGrid.getSelectedRecords();
+          }
+
+          if (selectedValues.length !== 1) {
+            // if there is not a single record selected, remove dummies
+            if (criterion.fieldName === isc.OBRestDataSource.DUMMY_CRITERION_NAME) {
+              shouldRemove = true;
+            }
+          } else {
+            // with a single record selected, removed false criterion
+            if (criterion.fieldName === 'id' && criterion.operator === 'equals' && criterion.value === '-1') {
+              shouldRemove = true;
+            }
+          }
         }
+
         if (shouldRemove) {
           internalCriteria.removeAt(i);
         } else {