Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0029254Openbravo ERPA. Platformpublic2015-03-12 09:562015-03-13 20:09
caristu 
AugustoMauch 
immediateminoralways
closedfixed 
5
pi 
3.0PR14Q3.83.0PR14Q3.8 
alostale
Core
Production - Confirmed Stable
2014-05-20
3.0PR14Q3
https://code.openbravo.com/erp/devel/pi/rev/d9ce373c75dad51598fb943d75e4d8e56f1d56eb [^]
No
0029254: Can't filter in numeric fields using the value 0
Is not possible to filter numeric fields using the value 0, the following error appears in the javascript console:

  "Uncaught TypeError: Cannot read property 'operator' of undefined"
1) Go to the Sales Order window
2) Try to filter by Delivery Status or Invoice Status fields , using the value 0
3) Notice that the filtering is not done and the error in description appears
Approved
caused by defect 0026305 closed guillermogil [PR14Q2]In column filter, when i enter ^511 and press tab, filter value gets deleted 
blocks defect 0029248 closed AugustoMauch Can't filter in numeric fields using the value 0 
Issue History
2015-03-12 11:33AugustoMauchTypedefect => backport
2015-03-12 11:33AugustoMauchTarget Version => 3.0PR14Q3.8
2015-03-12 17:07AugustoMauchIssue Monitored: alostale
2015-03-12 17:08AugustoMauchReview Assigned To => alostale
2015-03-12 17:08hgbotCheckin
2015-03-12 17:08hgbotNote Added: 0075496
2015-03-12 17:08hgbotStatusscheduled => resolved
2015-03-12 17:08hgbotResolutionopen => fixed
2015-03-12 17:08hgbotFixed in SCM revision => http://code.openbravo.com/erp/backports/3.0PR14Q3.8/rev/ea610afa4225516668fe5f6c86c9232ff8d12013 [^]
2015-03-13 11:06alostaleRelationship addedcaused by 0026305
2015-03-13 11:57alostaleNote Added: 0075539
2015-03-13 11:57alostaleStatusresolved => closed
2015-03-13 11:57alostaleFixed in Version => 3.0PR14Q3.8
2015-03-13 20:09dmitry_mezentsevTag Attached: Approved

Notes
(0075496)
hgbot   
2015-03-12 17:08   
Repository: erp/backports/3.0PR14Q3.8
Changeset: ea610afa4225516668fe5f6c86c9232ff8d12013
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Thu Mar 12 12:00:30 2015 +0100
URL: http://code.openbravo.com/erp/backports/3.0PR14Q3.8/rev/ea610afa4225516668fe5f6c86c9232ff8d12013 [^]

Fixes issue 29254: 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 [^]

---
M modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js
---
(0075539)
alostale   
2015-03-13 11:57   
code reviewed

tested in Sales Order delivery status (computed column) and total gross amount (regular column) with values:
-0
-100
->1000
-<1000
-^3 (as reported in 0026305, in this case the filter is removed as it is not supported textual filters in numeric columns)