details:   https://code.openbravo.com/erp/devel/pi/rev/66e71edf502a
changeset: 19656:66e71edf502a
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Tue Feb 12 13:29:13 2013 +0100
summary:   Fixes issue 22766: Information is not lost when saving a record with 
errors

The problem was that when a record was saved and in the saving process it was 
returned with validation errors, the record was being cleared from the grid. 
This happened because the List
Grid recordHasChanges function returned false (the record had changes indeed, 
in fact it was not yet saved in the database).

This has been fixed by overwritting the recordHasChanges function, so that it 
always returns true if the record had validation errors. In that case we can be 
sure that the record has ch
anges, because we know that a record with validation changes can not be saved 
in the database.

diffstat:

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

diffs (31 lines):

diff -r e3e84290cda6 -r 66e71edf502a 
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
     Tue Feb 12 13:23:48 2013 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Tue Feb 12 13:29:13 2013 +0100
@@ -2573,6 +2573,7 @@
     // set the default error message,
     // is possibly overridden in the next call
     if (record) {
+      record._hasValidationErrors = true;
       if (!record[isc.OBViewGrid.ERROR_MESSAGE_PROP]) {
         this.setRecordErrorMessage(rowNum, 
OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
         // do not automatically remove this message
@@ -2598,6 +2599,19 @@
     }
   },
 
+  recordHasChanges: function (rowNum) {
+    var record = this.getRecord(rowNum);
+    // If a record has validation errors but had all the mandatory fields set,
+    // smartclient's recordHasChanges will return false, and the record will 
be cleared (see ListGrid.hideInlineEditor function)
+    // In this case recordhasChanges should return true, because the values in 
the grid differ with the values in the database
+    // See issue https://issues.openbravo.com/view.php?id=22123
+    if (record && record._hasValidationErrors) {
+      return true;
+    } else {
+      return this.Super('recordHasChanges', arguments);
+    }
+  },
+
   editComplete: function (rowNum, colNum, newValues, oldValues, 
editCompletionEvent, dsResponse) {
 
     var record = this.getRecord(rowNum),

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to