[pi-process-multi-record] A null check has been added.
authorNaroa Iriarte <naroa.iriarte@openbravo.com>
Mon, 28 Nov 2016 15:07:38 +0100
changeset 31473 3da0c9000ddc
parent 31472 0f4dc3f4ee7e
child 31474 48b0e99812e3
[pi-process-multi-record] A null check has been added.

It is possible to have a process (for example add payment) called from a different kind of button. This caused a null pointer exception in the code of ob-parameter-window-view.doProcess. This is now avoided by a check.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js	Mon Nov 28 09:02:01 2016 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js	Mon Nov 28 15:07:38 2016 +0100
@@ -215,7 +215,7 @@
   handleResponse: function (refreshParent, message, responseActions, retryExecution, data) {
     var window = this.parentWindow,
         tab = OB.MainView.TabSet.getTab(this.viewTabId),
-        i, selectedRecords, afterRefreshCallback, me = this;
+        i, afterRefreshCallback, me = this;
 
     // change title to done
     if (tab) {
@@ -290,13 +290,12 @@
         }
       };
       if (refreshParent) {
-        if (this.callerField && this.callerField.view && typeof this.callerField.view.onRefreshFunction === 'function') {
-          // In this case we are inside a process called from another process, so we want to refresh the caller process instead of the main window.
-          this.callerField.view.onRefreshFunction(this.callerField.view);
+        if (this.button.multiRecord) {
+          this.buttonOwnerView.refresh(afterRefreshCallback);
         } else {
-
-          if (this.button.multiRecord) {
-            this.buttonOwnerView.refresh(afterRefreshCallback);
+          if (this.callerField && this.callerField.view && typeof this.callerField.view.onRefreshFunction === 'function') {
+            // In this case we are inside a process called from another process, so we want to refresh the caller process instead of the main window.
+            this.callerField.view.onRefreshFunction(this.callerField.view);
           } else {
             this.buttonOwnerView.refreshCurrentRecord(afterRefreshCallback);
           }
@@ -319,7 +318,7 @@
     var i, tmp, view = this,
         grid, allProperties, selection, len, allRows, params, tab, actionHandlerCall, clientSideValidationFail, selectedRecords, recordIds;
 
-    if (this.button.multiRecord) {
+    if (this.button && this.button.multiRecord) {
       selectedRecords = this.buttonOwnerView.viewGrid.getSelectedRecords();
       recordIds = [];
       for (i = 0; i < selectedRecords.length; i++) {