Fixes issue
22885: Dates in filters are serialized as Date, and not DateTime
The problem was that the Date was being serialized as a DateTime, and javascript was converting the resulting datetime to the UTC format.
I.e. if the user entered 24-01-2013, the date sent to the server for filtering was 23-01-2013 23:00:00. This conversion was being done when smartclient serialized the date. If the date had the logicalDate property set to true, then the conversion was done properly.
The change has been done only in the ob-formitem-minidaterange.js to ensure that the DateTime fields are serialized with both its date and time parts.
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js Fri Jan 25 14:23:32 2013 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js Fri Jan 25 14:31:21 2013 +0100
@@ -343,6 +343,7 @@
if (this.singleDateMode) {
dateValue = OB.Utilities.Date.OBToJS(newValue, this.dateFormat);
if (isc.isA.Date(dateValue)) {
+ dateValue.logicalDate = true;
this.singleDateValue = dateValue;
this.singleDateDisplayValue = newValue;
this.singleDateMode = true;
@@ -467,9 +468,27 @@
};
}
var criteria = this.rangeItem ? this.rangeItem.getCriterion() : null;
+ criteria = this.makeLogicalDates(criteria);
return criteria;
},
+ // Sets the logicalDate property to true to the date values contained in the criteria.
+ // This way the dates will always be serialized as a Date, and not as a DateTime
+ // See issue https://issues.openbravo.com/view.php?id=22885
+ makeLogicalDates: function (criteria) {
+ var criteriaCopy = isc.shallowClone(criteria),
+ innerCriteria = criteriaCopy.criteria,
+ i;
+ if (innerCriteria && innerCriteria.length) {
+ for (i = 0; i < innerCriteria.length; i++) {
+ if (isc.isA.Date(innerCriteria[i].value)) {
+ innerCriteria[i].value.logicalDate = true;
+ }
+ }
+ }
+ return criteriaCopy;
+ },
+
canEditCriterion: function (criterion) {
if (criterion.fieldName === this.name && (criterion.operator === 'isNull' || criterion.operator === 'notNull')) {