details:   https://code.openbravo.com/erp/devel/pi/rev/5a1da485df6b
changeset: 32790:5a1da485df6b
user:      Inigo Sanchez <inigo.sanchez <at> openbravo.com>
date:      Fri Sep 22 11:28:57 2017 +0200
summary:   Fixed issue 36611: Selection is lost when an error is raised 
removing a record

Backout changeset a6d788e3208b because some problems appears in the common case 
(succesful deletion). It is decided to fix the most uncommon case (failed 
deletion) by recovering the selection when the deletion fails.

As mentioned in the original fix, when were removing a row and an error was 
raising (e.g. Deleting a already processed "Good Shipment" is stopped by a 
trigger) the selection of the record was lost. This generates an inconsistent 
grid state that creates all
the reported problems.

Now the problem is fixed by take into account the described situation 
recovering the selection when the deletion fails. Now the selection is 
maintained if the record can't be removed properly.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 |  15 ++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diffs (46 lines):

diff -r cf859d178908 -r 5a1da485df6b 
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
 Fri Sep 22 10:40:47 2017 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Fri Sep 22 11:28:57 2017 +0200
@@ -2264,6 +2264,7 @@
           if (!localData) {
             // bail out, an error occured which should be displayed to the 
user now
             //clear deleting prompt
+            view.restoreGridSelection(selection);
             isc.clearPrompt();
             return;
           }
@@ -2314,6 +2315,7 @@
             }
             view.refreshParentRecord();
           } else {
+            view.restoreGridSelection(selection);
             // get the error message from the dataObject 
             if (localData.response && localData.response.error && 
localData.response.error.message) {
               error = localData.response.error;
@@ -2339,6 +2341,8 @@
           }
 
           selection = currentGrid.getSelection().duplicate();
+          // deselect the current records
+          currentGrid.deselectAllRecords();
           view.viewGrid.markForCalculateSummaries();
 
           if (selection.length > 1) {
@@ -2378,6 +2382,17 @@
     }
   },
 
+  restoreGridSelection: function (selection) {
+    var currentGrid;
+    if (this.isShowingTree) {
+      currentGrid = this.treeGrid;
+    } else {
+      currentGrid = this.viewGrid;
+    }
+    currentGrid.selection.selectList(selection);
+    currentGrid.fireSelectionUpdated();
+  },
+
   newRow: function (rowNum) {
     var actionObject = {
       target: this,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to