details: https://code.openbravo.com/erp/devel/pi/rev/edf09f403355 changeset: 24713:edf09f403355 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Mon Sep 29 17:41:21 2014 +0200 summary: Fixes issue 27706: fk filters work having several records with same identifier
The problem was that the new way if filtering foreign keys by using their ids instead of their identifiers did not support having several records with the same identifier. Note that this is a corner case, as it should not happen that two records in the same table have the same identifier. To fix this, the getRecordIdFromIdentifier function has been reworked to getRecordIdsFromIdentifier, because a given identifier can hit several records, each one with its own id. Now, if for instance the user clicks on the identifier x, and there are several records with the x identifier, all those records will be checked in the picklist. diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js | 23 ++++++--- 1 files changed, 14 insertions(+), 9 deletions(-) diffs (53 lines): diff -r a71fb71039f9 -r edf09f403355 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 Mon Sep 29 12:34:50 2014 +0200 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js Mon Sep 29 17:41:21 2014 +0200 @@ -560,7 +560,7 @@ getCriteriaValue: function () { var value, values = this.getValue(), record, i, criteriaValues = [], - recordId; + recordIds; if (values && this.filterType === 'id') { for (i = 0; i < values.length; i++) { value = values[i]; @@ -568,12 +568,12 @@ // if the value has the equals operator prefix, get rid of it value = value.substring(2); } - recordId = this.getRecordIdFromIdentifier(value); - if (!recordId) { + recordIds = this.getRecordIdsFromIdentifier(value); + if (!recordIds) { // if the record is not found or it does not have an id, use the standard criteria value return this.Super('getCriteriaValue', arguments); } else { - criteriaValues.add(recordId); + criteriaValues.addAll(recordIds); } } return criteriaValues; @@ -582,14 +582,19 @@ } }, - getRecordIdFromIdentifier: function (identifier) { - var recordId; + // given an identifier, returns an array of the filter picklist records that have that identifier + getRecordIdsFromIdentifier: function (identifier) { + var records, recordIds = [], + i; if (this.pickList && this.pickList.data.find(OB.Constants.IDENTIFIER, identifier)) { - recordId = this.pickList.data.find(OB.Constants.IDENTIFIER, identifier)[OB.Constants.ID]; + records = this.pickList.data.findAll(OB.Constants.IDENTIFIER, identifier); } else if (this.filterAuxCache && this.filterAuxCache.find(OB.Constants.IDENTIFIER, identifier)) { - recordId = this.filterAuxCache.find(OB.Constants.IDENTIFIER, identifier)[OB.Constants.ID]; + records = this.filterAuxCache.findAll(OB.Constants.IDENTIFIER, identifier); } - return recordId; + for (i = 0; i < records.length; i++) { + recordIds.add(records[i][OB.Constants.ID]); + } + return recordIds; }, getRecordIdentifierFromId: function (id) { ------------------------------------------------------------------------------ Slashdot TV. Videos for Nerds. Stuff that Matters. http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits