fixes issue 40743: wrong export to CSV having the grid filtered by a date time
authorCarlos Aristu <carlos.aristu@openbravo.com>
Mon, 06 May 2019 11:49:42 +0200
changeset 35627 2a604c499abc
parent 35626 240b635f238d
child 35628 0ec858b516d0
fixes issue 40743: wrong export to CSV having the grid filtered by a date time

After the following changeset[1], exporting the grid to CSV was not working properly having the grid filtered by a date time column. Although the fix is correct, it caused the criteria sent to the datasource in this type of requests to stop being handled properly.

To avoid this problem, when exporting to CSV a grid filtered by a date time column we send in the criteria the plain date (in the same way as it is being done for the standard grid DS requests) and the datasource will take care of building the date filter properly through the AdvancedQueryBuilder.

[1] https://code.openbravo.com/erp/devel/pi/rev/90ee5c965823996a7b4c0ae17d3a3ca71e3fc703
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Fri May 03 09:54:13 2019 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Mon May 06 11:49:42 2019 +0200
@@ -1244,6 +1244,7 @@
       _textMatchStyle: 'substring',
       _UTCOffsetMiliseconds: OB.Utilities.Date.getUTCOffsetInMiliseconds()
     }, lcriteria, this.getFetchRequestParams(null, isExporting));
+
     sortCriteria = this.getSort();
     if (sortCriteria && sortCriteria.length > 0) {
       d._sortBy = sortCriteria[0].property;
@@ -1251,6 +1252,13 @@
         d._sortBy = '-' + d._sortBy;
       }
     }
+
+    if (d.criteria) {
+      // Encode the grid criteria as it is done for the standard grid requests
+      // Note that OB.Utilities.postThroughHiddenForm has its own logic for encoding dates
+      d.criteria = isc.JSON.encode(d.criteria);
+    }
+
     OB.Utilities.postThroughHiddenForm(dsURL, d);
   },