details: https://code.openbravo.com/erp/devel/pi/rev/59a302602f2f changeset: 26167:59a302602f2f user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Thu Mar 12 12:00:30 2015 +0100 summary: Fixes issue 29248: 0 can be used to filter numeric columns
In this changeset [1] this code was added to the OBNumberItem.parseValueExpressions function: ret = this.Super('parseValueExpressions', [value, fieldName, operator]); + + // if operator is not supported remove it + if (!this.validOperators.contains(ret.operator)) { + ret.operator = ''; + ret.value = ''; + this.setValue(''); + } if (ret && ret.start) { ret.start = this.convertToTypedValue(ret.start); } The problem is that if the provided value is 0, this.Super('parseValueExpressions', [value, fieldName, operator]) will return undefined. This happens because of a bug in smartclient's implementation of the parseValueExpressions function. This code is placed at the beginning of that function: if (!value) value = this.getValue(); if (!value) return; if (!isc.isA.String(value)) value += ""; If the provided value is 0, the value will be taken from this.getValue(). The returned value will again be evaluated to false, so the function will not return any value. Right after that, there is a comman d to convert the provided value to String. To fix this, in the call to this.Super('parseValueExpressions'), the string representation of the number will be passed instead of its numerical value. This way smartclient will accept the value and will n ot return undefined. Smartclient was already converting the passed values to String, so there is no risk there. The value passed to the OBNumberItem.parseValueExpressions is not modified to prevent unexpected consequences. A copy of it is converted to string and passed to the this.Super('parseValueExpressions') func tion. [1] https://code.openbravo.com/erp/devel/pi/rev/d9ce373c75dad51598fb943d75e4d8e56f1d56eb diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diffs (25 lines): diff -r e282c64e6e90 -r 59a302602f2f modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js Thu Mar 12 10:39:35 2015 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js Thu Mar 12 12:00:30 2015 +0100 @@ -558,13 +558,19 @@ }, parseValueExpressions: function (value, fieldName, operator) { - var ret; + var ret, strValue; + + // smartclient's implementation of parseValueExpressions does not work properly of the formitem value is 0 + // this can be circumvented by passing a string instead of a number (the original value is not modified) if (isc.isA.String(value)) { value = value.trim(); + strValue = value; + } else { + strValue = String(value); } - ret = this.Super('parseValueExpressions', [value, fieldName, operator]); + ret = this.Super('parseValueExpressions', [strValue, fieldName, operator]); // if operator is not supported remove it if (!this.validOperators.contains(ret.operator)) { ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits