fixed bug 22645: tabs without explicit reference to parent id are not refreshed
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 25 Jan 2013 18:55:48 +0100
changeset 19453 c141a066c7d0
parent 19451 98f945713fd4
child 19454 b1526c3b0148
fixed bug 22645: tabs without explicit reference to parent id are not refreshed

The problem was as the subtab was not explicitly setting its parent record (it
was done through where clause), when changing selection in parent an empty
criteria was created preventing request to datasource of being done.

The fix creates for this case a dummy criteria to force request to be triggered.
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	Fri Jan 25 15:26:55 2013 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Jan 25 18:55:48 2013 +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-2012 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -1873,6 +1873,25 @@
       }
     }
 
+    if (this.view.parentView && !this.view.parentProperty) {
+      // subtabs without an explicit reference to their parent property
+      // result in an empty criteria which is ignored not generating the
+      // request. Forcing load
+      // See issue #22645
+      selectedValues = this.view.parentView.viewGrid.getSelectedRecords();
+      if (selectedValues.length !== 1) {
+        // if there is not a single record selected, always false criterion
+        criteria.criteria.push({
+          fieldName: 'id',
+          operator: 'equals',
+          value: '-1'
+        });
+      } else {
+        // with a single record selected, dummy criterion
+        criteria.criteria.push(isc.OBRestDataSource.getDummyCriterion());
+      }
+    }
+
     this.checkShowFilterFunnelIcon(criteria);
 
     return criteria;