details: https://code.openbravo.com/erp/devel/pi/rev/de50252ad892 changeset: 30675:de50252ad892 user: Inigo Sanchez <inigo.sanchez <at> openbravo.com> date: Wed Nov 23 15:32:15 2016 +0100 summary: Fixed issue 33792:In P&E windows, filter drop down options disappear sometimes
The problem was in P&E windows using filter dropdown. First time all were working fine but the second time, when filter dropdown was open and a filter option was previously selected, filter dropdown options were disappear. To reproduce this problem it was necessary to have a selected record in P&E. When filter dropdown options were disappear, the request had some extra parameters. This extra parameters were a problem in order to build the query properly. These were the extra parameters: _constructor:AdvancedCriteria _OrExpression:true operator:or At the end these parameters build a bad query because main alias was not managed properly in the server side. As a result of the operator parameter (operator:or) main alias was not use properly. The query was built poorly due to the aliases. To solve the problem now, when cleanCriteria function is executed, it is also executed cleanOrCriterion function in order to clean criteria properly. diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js | 23 +++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diffs (53 lines): diff -r 33576bf5296b -r de50252ad892 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 Tue Nov 22 13:15:57 2016 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js Wed Nov 23 15:32:15 2016 +0100 @@ -331,6 +331,10 @@ gridCriteria, criteriaFieldName = this.getCriteriaFieldName(), me = this; + function isInPickAndExecuteGrid() { + return (me.grid && me.grid.parentElement && me.grid.parentElement.getClassName() === 'OBPickAndExecuteGrid'); + } + function cleanCriteria(crit, fkItem) { var i, criterion, fkFilterOnThisField; for (i = crit.length - 1; i >= 0; i--) { @@ -347,13 +351,29 @@ crit.removeAt(i); } - if (me.grid && me.grid.parentElement && me.grid.parentElement.getClassName() === 'OBPickAndExecuteGrid' && criterion.fieldName === 'id') { + if (isInPickAndExecuteGrid() && criterion.fieldName === 'id') { // we're in a P&E grid, selected ids should also be removed from criteria crit.removeAt(i); } } } + function cleanOrCriterion() { + if (isInPickAndExecuteGrid() && gridCriteria._OrExpression) { + //we need to delete _OrExpression parameter in a P&E grid regarding avoid include selection into criteria. + if (gridCriteria.criteria.length > 0) { + gridCriteria = { + operator: 'and', + _constructor: 'AdvancedCriteria', + criteria: gridCriteria.criteria + }; + } else { + gridCriteria = {}; + gridCriteria.criteria = []; + } + } + } + if (this.form.grid.sourceWidget.lazyFiltering) { // Fetch the criteria from the current values of the filter editor // Invoke the convertCriteria function to filter by the record selected in the parent tab if needed @@ -371,6 +391,7 @@ // remove from criteria the field used for current filter so drop down doesn't // restrict its values cleanCriteria(gridCriteria.criteria); + cleanOrCriterion(); if (this.form.grid.sourceWidget && this.form.grid.sourceWidget.dataSource) { gridCriteria = this.form.grid.sourceWidget.dataSource.convertRelativeDates(gridCriteria); ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits