Related to issue 26231: getParentRecord returns the proper record
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 10 Apr 2014 18:41:31 +0200
changeset 22906 b72329997994
parent 22905 2107a74db26b
child 22907 ded41677a214
Related to issue 26231: getParentRecord returns the proper record

The getParentRecord was returning the record selected in the standard grid view of the parent tab, even if it was showing the tree view grid. This resulted in that if the subtab had only one record, the tab display logic was not working properly.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Thu Apr 10 18:30:33 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Thu Apr 10 18:41:31 2014 +0200
@@ -1527,6 +1527,7 @@
   },
 
   getParentRecord: function () {
+    var grid = null;
     if (!this.parentView || !this.parentView.viewGrid.getSelectedRecords() || this.parentView.viewGrid.getSelectedRecords().length !== 1) {
       return null;
     }
@@ -1535,8 +1536,12 @@
     if (this.parentView.viewGrid.getSelectedRecord()._new) {
       return null;
     }
-
-    return this.parentView.viewGrid.getSelectedRecord();
+    if (this.isShowingTree) {
+      grid = this.parentView.treeGrid;
+    } else {
+      grid = this.parentView.viewGrid;
+    }
+    return grid.getSelectedRecord();
   },
 
   updateTabTitle: function () {