Fixes issue 29010: Grid is actually filtered using relative dates
authorAugusto Mauch <augusto.mauch@openbravo.com>
Tue, 24 Feb 2015 22:16:04 +0100
changeset 26070 9645a99f1336
parent 26069 f24821411d25
child 26072 694b64ebdb05
Fixes issue 29010: Grid is actually filtered using relative dates

The problem was that when a relative date filter was added to the grid and then used in a saved view, the saved view will not apply the relative date filter, but an absolute one. This was caused by this code in the OBViewGrid.convertCriteria function:

if (this.dataSource) {
criteria = this.dataSource.convertRelativeDates(criteria);
}

Every time that a criteria is sent to the backend (i.e. when storing a saved view), the criteria objects that contained relative dates wwere converted to absolute dates. This was done to fix this issue
[1], its problem being that the datasource used to populate the filter drop down did not support relative dates.

The function where that code was placed was too central, the criterias converted should have been only the ones used to populate the filter drop downs, but all the criterias were being converted. To fix this, the code has been adapted and moved to the OBFKFilterTextItem.getPickListFilterCriteria function.
[1] https://issues.openbravo.com/view.php?id=27679
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Tue Feb 24 19:00:32 2015 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Tue Feb 24 22:16:04 2015 +0100
@@ -362,6 +362,10 @@
     // restrict its values
     cleanCriteria(gridCriteria.criteria);
 
+    if (this.form.grid.sourceWidget && this.form.grid.sourceWidget.dataSource) {
+      gridCriteria = this.form.grid.sourceWidget.dataSource.convertRelativeDates(gridCriteria);
+    }
+
     // when in refresh picklist the user is typing
     // a value, filter using that
     if (this.keyPressed && pickListCriteria) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Tue Feb 24 19:00:32 2015 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Tue Feb 24 22:16:04 2015 +0100
@@ -2024,9 +2024,6 @@
     // note pass in criteria otherwise infinite looping!
     this.resetEmptyMessage(criteria);
     //convert relative dates to absolute dates. Refer issue https://issues.openbravo.com/view.php?id=27679
-    if (this.dataSource) {
-      criteria = this.dataSource.convertRelativeDates(criteria);
-    }
     if (this.view.parentProperty && !this.isOpenDirectMode) {
       if (this.view.parentView.isShowingTree) {
         selectedValues = this.view.parentView.treeGrid.getSelectedRecords();