Fixes issue 20278: [SC Upgrade] You can not save twice a form after upgrade to SC 8.3d 2012-03-12 (or later)
authorMartin Taal <martin.taal@openbravo.com>
Wed, 18 Apr 2012 19:52:14 +0200
changeset 16324 042e65fa947c
parent 16323 f90c1a09777f
child 16325 ae87616ffeef
Fixes issue 20278: [SC Upgrade] You can not save twice a form after upgrade to SC 8.3d 2012-03-12 (or later)
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-datetime.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-datetime.js	Tue Apr 17 20:28:58 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-datetime.js	Wed Apr 18 19:52:14 2012 +0200
@@ -133,6 +133,19 @@
     return value;
   },
 
+  // compare on seconds, ignoring less than
+  // 1 sec difference
+  // related to https://issues.openbravo.com/view.php?id=20278  
+  compareValues: function (a, b) {
+    if (a === b) {
+      return 0; // same date instance
+    }
+    var aval = (isc.isA.Date(a) ? a.getTime() : 0),
+      bval = (isc.isA.Date(b) ? b.getTime() : 0),
+      diff = aval - bval;
+    return diff > 1000 ? -1 : (diff < -1000 ? 1 : 0); 
+  },
+
   parseValue: function () {
     return this.dateTextField.getElementValue();
   },
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Tue Apr 17 20:28:58 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Wed Apr 18 19:52:14 2012 +0200
@@ -1491,6 +1491,11 @@
 
       form.isSaving = false;
       view.toolBar.updateButtonState(true);
+      
+      // needed until save refreshes form items in the 
+      // correct way
+      // https://issues.openbravo.com/view.php?id=20278
+      form.markForRedraw();
       return false;
     };
 
@@ -1523,6 +1528,16 @@
     return true;
   },
 
+  // overridden as the super does not compare all values
+  // correctly:
+  // https://issues.openbravo.com/view.php?id=20278
+  fieldValuesAreEqual: function(field, value1, value2) {
+    if (field && field.compareValues) {
+      return 0 === field.compareValues(value1, value2);
+    }
+    return this.Super('fieldValuesAreEqual', arguments);
+  },
+  
   // called when someone picks something from a picklist, the focus should go to the next
   // item
   focusInNextItem: function (currentItemName) {