[absref] Fixed issue 26287: Abs DateTime now display always the same value
authorDavid Baz Fayos <david.baz@openbravo.com>
Thu, 17 Apr 2014 01:22:39 +0200
changeset 22932 bdd43e2b23bd
parent 22931 2aa45e3949b4
child 22933 393ff5c59853
[absref] Fixed issue 26287: Abs DateTime now display always the same value
whether the field be shown in grid view or not
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
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/form/ob-view-form.js	Wed Apr 16 18:39:51 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Thu Apr 17 01:22:39 2014 +0200
@@ -1041,6 +1041,11 @@
         }
       } else if (isAbsoluteDateTime) {
         jsDateTime = isc.Date.parseStandardDate(columnValue.value);
+        // In the case of an absolute datetime, it needs to be converted in order to avoid the UTC conversion
+        // http://forums.smartclient.com/showthread.php?p=116135
+        if (Object.prototype.toString.call(jsDateTime) === '[object Date]') {
+          jsDateTime = OB.Utilities.Date.substractTimezoneOffset(jsDateTime);
+        }
         this.setItemValue(field.name, jsDateTime);
         if (field.textField) {
           delete field.textField._textChanged;
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed Apr 16 18:39:51 2014 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Thu Apr 17 01:22:39 2014 +0200
@@ -2249,6 +2249,13 @@
         propertyObj = properties[i];
         value = record[propertyObj.property];
         field = component.getField(propertyObj.property);
+        if (field && field.editorType //
+        && Object.prototype.toString.call(value) === '[object Date]' //
+        && new Function('return isc.' + field.editorType + '.getPrototype().isAbsoluteDateTime')()) { //
+          // In the case of an absolute datetime, it needs to be converted in order to avoid the UTC conversion
+          // http://forums.smartclient.com/showthread.php?p=116135
+          value = OB.Utilities.Date.addTimezoneOffset(value);
+        }
         addProperty = propertyObj.sessionProperty || !onlySessionProperties;
         if (addProperty) {
           if (classicMode) {