diff --git a/org.adempiere.base/src/org/compiere/model/MQuery.java b/org.adempiere.base/src/org/compiere/model/MQuery.java index 9b7a03dbd6..d696ede3e8 100644 --- a/org.adempiere.base/src/org/compiere/model/MQuery.java +++ b/org.adempiere.base/src/org/compiere/model/MQuery.java @@ -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; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java index 6800b3ce09..0e76450a06 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java @@ -1699,7 +1699,7 @@ public class FindWindow extends Window implements EventListener, 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, 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, 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 categories = new Vector(100); PreparedStatement pstmt = null;