From b4dcfa11d92f9fd9a8558139619f59173d30e166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Mon, 26 Jun 2023 16:06:27 +0200 Subject: [PATCH] IDEMPIERE-5770 - Sql clauses are not applied on Related Info Window (#1897) * IDEMPIERE-5770 - Sql clauses are not applied on Related Info Window * IDEMPIERE-5770 - surround where clause with parenthesis --- .../src/org/adempiere/webui/info/InfoWindow.java | 3 +++ .../org/adempiere/webui/info/RelatedInfoWindow.java | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java index 4f3f507ffb..2087840222 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java @@ -873,6 +873,9 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL String s_sqlFrom = embedInfo.getFromClause(); /** Where Clause */ String s_sqlWhere = relatedInfo.getLinkColumnName() + "=?"; + String infoWhere = embedInfo.getWhereClause(); + if(!Util.isEmpty(infoWhere)) + s_sqlWhere += " AND (" + infoWhere + ")"; String s_sqlCount = "SELECT COUNT(*) FROM " + s_sqlFrom + " WHERE " + s_sqlWhere; m_sqlEmbedded = embeddedTbl.prepareTable(s_layoutEmbedded, s_sqlFrom, s_sqlWhere, false, tableName); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/RelatedInfoWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/RelatedInfoWindow.java index 3c6d02f196..8337748283 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/RelatedInfoWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/RelatedInfoWindow.java @@ -328,9 +328,22 @@ public class RelatedInfoWindow implements EventListener, Sortable long startTime = System.currentTimeMillis(); dataSql = info.getInfoSql(); + + // Other Clause and Order By clause + String otherClause = info.getInfowin().getOtherClause(); + String orderByClause = info.getInfowin().getOrderByClause(); + if (!Util.isEmpty(otherClause)) { + dataSql = dataSql + " " + otherClause; + } if (!Util.isEmpty(m_sqlUserOrder)) { dataSql = dataSql + m_sqlUserOrder; + if(!Util.isEmpty(orderByClause)) + dataSql = dataSql + orderByClause; } + else if(!Util.isEmpty(orderByClause)) { + dataSql = dataSql + " ORDER BY " + orderByClause; + } + // isHasNextPage = false; if (log.isLoggable(Level.FINER)) log.finer(dataSql);