Fixes issue 21764: Only the proper records are shown after completing an order
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 26 Sep 2012 14:15:54 +0200
changeset 18025 22cb1b467fde
parent 18024 cce05b691662
child 18051 74734fd26fcf
Fixes issue 21764: Only the proper records are shown after completing an order

The problem was caused by the fix of the issue 21437. Some logic was added to ensure that the recently created records were shown after completing a process, even if the do not comply with the filters. The problem was that this was done on a tab level, without taking into account that their parent record might not be the same.

This has been fixed, and only the child records of the current parent record are shown.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Wed Sep 26 12:55:20 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Wed Sep 26 14:15:54 2012 +0200
@@ -1493,10 +1493,20 @@
           return;
         }
 
-        if (!view.newRecordsAfterRefresh) {
-          view.newRecordsAfterRefresh = [];
+        if (view.parentRecordId) {
+          if (!view.newRecordsAfterRefresh) {
+            view.newRecordsAfterRefresh = {};
+          }
+          if (!view.newRecordsAfterRefresh[view.parentRecordId]) {
+            view.newRecordsAfterRefresh[view.parentRecordId] = [];
+          }
+          view.newRecordsAfterRefresh[view.parentRecordId].push(data[OB.Constants.ID]);
+        } else {
+          if (!view.newRecordsAfterRefresh) {
+            view.newRecordsAfterRefresh = [];
+          }
+          view.newRecordsAfterRefresh.push(data[OB.Constants.ID]);
         }
-        view.newRecordsAfterRefresh.push(data[OB.Constants.ID]);
 
         // do this after doing autoSave as the setHasChanged will clean
         // the autosave info
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Wed Sep 26 12:55:20 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Wed Sep 26 14:15:54 2012 +0200
@@ -2314,10 +2314,20 @@
     saveCallback = function () {
       if (originalCallback) {
         if (this.getSelectedRecord() && this.getSelectedRecord()[OB.Constants.ID]) {
-          if (!this.view.newRecordsAfterRefresh) {
-            this.view.newRecordsAfterRefresh = [];
+          if (this.view.parentRecordId) {
+            if (!this.view.newRecordsAfterRefresh) {
+              this.view.newRecordsAfterRefresh = {};
+            }
+            if (!this.view.newRecordsAfterRefresh[this.view.parentRecordId]) {
+              this.view.newRecordsAfterRefresh[this.view.parentRecordId] = [];
+            }
+            this.view.newRecordsAfterRefresh[this.view.parentRecordId].push(this.getSelectedRecord()[OB.Constants.ID]);
+          } else {
+            if (!this.view.newRecordsAfterRefresh) {
+              this.view.newRecordsAfterRefresh = [];
+            }
+            this.view.newRecordsAfterRefresh.push(this.getSelectedRecord()[OB.Constants.ID]);
           }
-          this.view.newRecordsAfterRefresh.push(this.getSelectedRecord()[OB.Constants.ID]);
         }
         this.fireCallback(originalCallback, "rowNum,colNum,editCompletionEvent,success", [rowNum, colNum, editCompletionEvent]);
       }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed Sep 26 12:55:20 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed Sep 26 14:15:54 2012 +0200
@@ -1415,7 +1415,11 @@
     };
 
     if (!newRecordsToBeIncluded) {
-      this.newRecordsAfterRefresh = [];
+      if (this.parentRecordId) {
+        this.newRecordsAfterRefresh[this.parentRecordId] = [];
+      } else {
+        this.newRecordsAfterRefresh = [];
+      }
     }
     if (!this.isShowingForm) {
       this.viewGrid.refreshGrid(refreshCallback, newRecordsToBeIncluded);
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js	Wed Sep 26 12:55:20 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js	Wed Sep 26 14:15:54 2012 +0200
@@ -146,7 +146,7 @@
     afterRefresh = function (doRefresh) {
       var undef, refresh = (doRefresh === undef || doRefresh),
           autosaveDone = false,
-          currentRecordId;
+          currentRecordId, recordsAfterRefresh;
 
       // Refresh context view
       contextView.getTabMessage();
@@ -162,7 +162,12 @@
         // The selected record should be shown after the refresh, even
         // if the filter would exclude it
         // See issue https://issues.openbravo.com/view.php?id=20722
-        currentView.refresh(null, autosaveDone, currentView.newRecordsAfterRefresh);
+        if (currentView.parentTabId) {
+          recordsAfterRefresh = currentView.newRecordsAfterRefresh[currentView.parentTabId];
+        } else {
+          recordsAfterRefresh = currentView.newRecordsAfterRefresh;
+        }
+        currentView.refresh(null, autosaveDone, recordsAfterRefresh);
       }
     };