Fixes issue 24491: DateTime fields can be modified from callouts
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 21 Aug 2013 13:24:36 +0200
changeset 21006 f0180754bd11
parent 21005 c56eb50a9239
child 21007 8008267023a0
Fixes issue 24491: DateTime fields can be modified from callouts

The problem was the following:
- The current value of the datetime field is, i.e., 05-06-2013 10:00:00
- The callout tries to change it to another datetime, but not modifying the date part, i.e. 05-06-2013 11:45:00
- In order to check if the value of the field needed to be changed, the function isc.Date.compareLogicalDates(newValue, oldValue) was used. This function only
checks the date part of the value. In this case the date part is the same, so the change was not applied.

To fix this, datetime fields use isc.Date.compareDates (which compares both the date and the time parts) instead of isc.Date.compareLogicalDates.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-datetime.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-datetime.js	Wed Aug 21 13:15:36 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-datetime.js	Wed Aug 21 13:24:36 2013 +0200
@@ -174,6 +174,10 @@
     date = this.getValue();
     date.setHours(now.getHours(), now.getMinutes(), now.getSeconds());
     this.setValue(date);
+  },
+
+  compareValues: function (value1, value2) {
+    return (0 === isc.Date.compareDates(value1, value2));
   }
 });