Fixes bug 28220:FK no longer filtered without applying selected parent criteria
authorAugusto Mauch <augusto.mauch@openbravo.com>
Tue, 18 Nov 2014 18:43:55 +0100
changeset 24097 0e3759683845
parent 24096 a6bf203d3fff
child 24098 7432c922f533
Fixes bug 28220:FK no longer filtered without applying selected parent criteria

The problem was the following. If a tab was configured to use lazy filtering, when one of its foreign keys is filtered the criteria is obtained from the current values of the filter editor, instead of directly calling the getCriteria function of the grid.

The problem is that the criteria was not being passed to the OBViewGrid.convertCriteria function, which among other things adds the criteria to filter by the record selected in the parent tab. The result was that the dropdown contained way more records than it should, and that the query to retrieve the records could have very bad performance if the table associated with the tab contained many records.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Wed Nov 19 10:40:03 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Tue Nov 18 18:43:55 2014 +0100
@@ -244,7 +244,8 @@
 
     if (this.form.grid.sourceWidget.lazyFiltering) {
       // Fetch the criteria from the current values of the filter editor
-      gridCriteria = this.form.grid.getValues();
+      // Invoke the convertCriteria function to filter by the record selected in the parent tab if needed
+      gridCriteria = this.grid.sourceWidget.convertCriteria(this.form.grid.getValues());
     } else {
       gridCriteria = this.form.grid.sourceWidget.getCriteria();
     }