Fixes issue 29092: Inconsistent data is not shown in the form view
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 12 Mar 2015 10:39:35 +0100
changeset 26167 e282c64e6e90
parent 26165 ac9670b7bfdd
child 26168 59a302602f2f
Fixes issue 29092: Inconsistent data is not shown in the form view

This issue was reproduced in the following scenario:
- A subtab is open in form view
- A change is done in its parent tab. That change (either through an event handler or through a trigger) deletes the record selected in the subtab and creates a new one
- The subtab is automatically refreshed. When the tab is refreshed:
* The whole grid is reloaded, it now contains all the current records
* The form view is shown again, and it tries to obtain the updated records from the grid. As the record selected in the form view is not present in the grid, the form view contains the old values

To fix this, when the record that was selected in the form view is no longer contained in the grid after the tab is refreshed, the form view is not shown. This was the grid view will be visible, and it will show the updated info.
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	Wed Mar 11 13:23:31 2015 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Thu Mar 12 10:39:35 2015 +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-2014 Openbravo SLU
+ * All portions are Copyright (C) 2010-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -1228,7 +1228,11 @@
           me.viewGrid.selectRecord(recordIndex);
         }
         if (me.formVisibleBeforeRefresh) {
-          me.switchFormGridVisibility();
+          if (me.viewGrid.getRecordIndex(me.viewForm.getValues()) !== -1) {
+            // it might be that the record selected in the form is no longer present in the grid after being refreshed, due to having been deleted
+            // in that case do not switch to form view, and keep the grid view to show the currently existing records
+            me.switchFormGridVisibility();
+          }
         }
         delete me.formVisibleBeforeRefresh;
         delete me.viewGrid.recordsSelectedBeforeRefresh;