# HG changeset patch
# User Javier Armendáriz <javier.armendariz@openbravo.com>
# Date 1545667926 -3600
#      Mon Dec 24 17:12:06 2018 +0100
# Node ID 591832bbd3b6a6bb3e0906dfaf0e6ec1cdbc8d22
# Parent  2730a1285660035e5115b25f10c0dfdb0e4f34da
Fixes issue 39218: Hidden value in grid not updated when edited in process

This changeset removes the edit values in the selected fields either after
refreshing the grid view or when returning from a process to make sure the
values passed are always up-to-date.

diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js b/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
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
@@ -1712,6 +1712,8 @@
     }
     this.resetEmptyMessage();
 
+    this.discardAllEdits();
+
     var record, ret = this.Super('dataArrived', arguments);
     this.updateRowCountDisplay();
 
diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js b/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
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js
@@ -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) 2012-2017 Openbravo SLU
+ * All portions are Copyright (C) 2012-2018 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -283,11 +283,20 @@
     if (this.popup && !retryExecution) {
       this.buttonOwnerView.setAsActiveView();
       afterRefreshCallback = function () {
+        var selectedRecords, i;
+
         if (me.buttonOwnerView && isc.isA.Function(me.buttonOwnerView.refreshParentRecord) && isc.isA.Function(me.buttonOwnerView.refreshChildViews)) {
           me.buttonOwnerView.refreshParentRecord();
           me.buttonOwnerView.refreshChildViews();
           me.buttonOwnerView.toolBar.updateButtonState();
         }
+
+        if(me.buttonOwnerView && me.buttonOwnerView.viewGrid && isc.isA.Function(me.buttonOwnerView.viewGrid.getSelectedRecords) && isc.isA.Function(me.buttonOwnerView.viewGrid.discardEdits)) {
+          selectedRecords = me.buttonOwnerView.viewGrid.getSelectedRecords();
+          for (i=0; i < selectedRecords.length; i++) {
+              me.buttonOwnerView.viewGrid.discardEdits(selectedRecords[i]);
+          }
+        }
       };
       if (refreshParent) {
         if (this.button && this.button.multiRecord) {
