From 46c7c4c06d35eaaefde413edd0af28dccb3076eb Mon Sep 17 00:00:00 2001 From: Diego Ruiz <12065321+d-ruiz@users.noreply.github.com> Date: Wed, 18 Oct 2023 09:00:37 +0200 Subject: [PATCH] IDEMPIERE-5773 - Fixed bug on advance detail not adding the parenthesis on detail tab queries (#2062) * IDEMPIERE-5773 - Refactor FindWindow code that discovers the right and left bracket value * IDEMPIERE-5773 - Refactor FindWindow code that discovers the right and left bracket value - Improve method name * IDEMPIERE-5773 - Fixed bug on advance detail not adding the parenthesis on detail tab queries --- .../adempiere/webui/window/FindWindow.java | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) 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 723d0a040f..3143f34fa2 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 @@ -2264,15 +2264,18 @@ public class FindWindow extends Window implements EventListener, ValueCha exists.append(PO.getUUIDColumnName(m_tableName)); else exists.append(m_tableName).append("_ID "); - ColumnSQL = exists.toString() + " AND " + ColumnSQL; + + exists.append(" AND ") + .append(getLeftBracketValue(row)) + .append(ColumnSQL); + ColumnSQL = exists.toString(); } isExists = true; } } // Left brackets - Listbox listLeftBracket = (Listbox)row.getFellow("listLeftBracket"+row.getId()); - String lBrackets = listLeftBracket.getSelectedItem().getValue().toString(); + String lBrackets = getLeftBracketValue(row); if (lBrackets != null) { openBrackets += lBrackets.length(); if (isExists && !lBrackets.isEmpty()) { @@ -2283,8 +2286,7 @@ public class FindWindow extends Window implements EventListener, ValueCha lBrackets = ""; } // Right brackets - Listbox listRightBracket = (Listbox)row.getFellow("listRightBracket"+row.getId()); - String rBrackets = listRightBracket.getSelectedItem().getValue().toString(); + String rBrackets = getRightBracketValue(row); if (rBrackets != null) { openBrackets -= rBrackets.length(); if(isCompositeExists && !rBrackets.isEmpty()) @@ -2468,6 +2470,8 @@ public class FindWindow extends Window implements EventListener, ValueCha if(!isCompositeExists) where += ")"; + + where += getRightBracketValue(row); m_query.addRestriction(where, and, not, isExistCondition, openBrackets); } else { @@ -2489,6 +2493,28 @@ public class FindWindow extends Window implements EventListener, ValueCha } } // cmd_saveAdvanced + + /** + * Returns the value selected for the left bracket list item + * in the current row + * @param row + * @return empty, (, (( or ((( + */ + private String getLeftBracketValue(ListItem row) { + Listbox listLeftBracket = (Listbox)row.getFellow("listLeftBracket"+row.getId()); + return listLeftBracket.getSelectedItem().getValue().toString(); + } + + /** + * Returns the value selected for the right bracket list item + * in the current row + * @param row + * @return empty, ), )) or ))) + */ + private String getRightBracketValue(ListItem row) { + Listbox listRightBracket = (Listbox)row.getFellow("listRightBracket"+row.getId()); + return listRightBracket.getSelectedItem().getValue().toString(); + } /** * Append values to code