diff --git a/org.adempiere.base/src/org/compiere/print/DataEngine.java b/org.adempiere.base/src/org/compiere/print/DataEngine.java index 866615fb72..9fd9acacfa 100644 --- a/org.adempiere.base/src/org/compiere/print/DataEngine.java +++ b/org.adempiere.base/src/org/compiere/print/DataEngine.java @@ -171,8 +171,13 @@ public class DataEngine reportName = rs.getString(3); // Add WhereClause restriction from AD_ReportView - teo_sarca BF [ 1761891 ] String whereClause = rs.getString(4); - if (!Util.isEmpty(whereClause)) - queryCopy.addRestriction(whereClause); + if (!Util.isEmpty(whereClause)) { + if (whereClause.indexOf("@") == -1) { + query.addRestriction(whereClause); + } else { // replace context variables + query.addRestriction(Env.parseContext(ctx, 0, whereClause.toString(), false, true)); + } + } } } catch (SQLException e) diff --git a/org.adempiere.base/src/org/compiere/print/ReportEngine.java b/org.adempiere.base/src/org/compiere/print/ReportEngine.java index bc41248960..ebbfb2d69a 100644 --- a/org.adempiere.base/src/org/compiere/print/ReportEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ReportEngine.java @@ -1125,7 +1125,6 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) int AD_Table_ID = 0; int AD_ReportView_ID = 0; String TableName = null; - String whereClause = ""; int AD_PrintFormat_ID = 0; boolean IsForm = false; int Client_ID = -1; @@ -1152,9 +1151,6 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) if (rs.next()) { AD_ReportView_ID = rs.getInt(1); // required - whereClause = rs.getString(2); - if (rs.wasNull()) - whereClause = ""; // AD_Table_ID = rs.getInt(3); TableName = rs.getString(4); // required for query @@ -1188,7 +1184,6 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) rs = pstmt.executeQuery(); if (rs.next()) { - whereClause = ""; AD_Table_ID = rs.getInt(1); TableName = rs.getString(2); // required for query AD_PrintFormat_ID = rs.getInt(3); // required @@ -1223,10 +1218,6 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) { query = MQuery.get (ctx, pi.getAD_PInstance_ID(), TableName); } - - // Add to static where clause from ReportView - if (whereClause.length() != 0) - query.addRestriction(whereClause); // Get Print Format MPrintFormat format = null;