IDEMPIERE-3975: Virtual column can't be used for search, empty result returned

This commit is contained in:
Deepak Pansheriya 2019-05-17 19:18:40 +05:30
parent cf0d10a3e6
commit a9fbf53acf
2 changed files with 6 additions and 5 deletions

View File

@ -1126,7 +1126,7 @@ class Restriction implements Serializable
String colSQL = col.getColumnSQL(true);
if (colSQL != null && colSQL.contains("@"))
colSQL = Env.parseContext(Env.getCtx(), -1, colSQL, false, true);
if (ColumnName.equals(colSQL)) {
if (colSQL != null && ColumnName.equals(colSQL.trim())) {
virtualColumn = true;
break;
}

View File

@ -1699,7 +1699,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
if (!(parsedValue instanceof Integer)) {
continue;
}
m_query.addRestriction(getSubCategoryWhereClause(((Integer) parsedValue).intValue()), and, openBrackets);
m_query.addRestriction(getSubCategoryWhereClause(field, ((Integer) parsedValue).intValue()), and, openBrackets);
}
else
m_query.addRestriction(ColumnSQL, Operator, parsedValue,
@ -1865,7 +1865,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
m_query.addRestriction(ColumnSQL.toString(), MQuery.LIKE, value, ColumnName, wed.getDisplay());
appendCode(code, ColumnName, MQuery.LIKE, value.toString(), "", "AND", "", "");
} else if (isProductCategoryField && value instanceof Integer) {
m_query.addRestriction(getSubCategoryWhereClause(((Integer) value).intValue()));
m_query.addRestriction(getSubCategoryWhereClause(field, ((Integer) value).intValue()));
appendCode(code, ColumnName, MQuery.EQUAL, value.toString(), "", "AND", "", "");
} else {
String oper = MQuery.EQUAL;
@ -2319,13 +2319,14 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
/**
* Returns a sql where string with the given category id and all of its subcategory ids.
* It is used as restriction in MQuery.
* @param field
* @param productCategoryId
* @return
**/
private String getSubCategoryWhereClause(int productCategoryId) {
private String getSubCategoryWhereClause(GridField field, int productCategoryId) {
//if a node with this id is found later in the search we have a loop in the tree
int subTreeRootParentId = 0;
StringBuilder retString = new StringBuilder(" M_Product_Category_ID IN (");
StringBuilder retString = new StringBuilder(field.getColumnSQL(false)).append(" IN (");
String sql = "SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category WHERE AD_Client_ID=? AND IsActive='Y'";
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
PreparedStatement pstmt = null;