From 7d5d6040955bd95f3895fb5cabbb867fc588f20d Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 17 Dec 2014 16:41:58 -0500 Subject: [PATCH] Fix for IDEMPIERE-1878 Printformat name in login language / throwing exception SEVERE: TableName not correctly parsed - TableNameIn=AD_PrintFormat - AccessSqlParser[|0] --- .../src/org/compiere/print/MPrintFormat.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java index 3a03d8dedf..593a9a8a6a 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java @@ -1171,22 +1171,23 @@ public class MPrintFormat extends X_AD_PrintFormat */ public static List getAccessiblePrintFormats (int AD_Table_ID, int AD_Window_ID, String trxName, boolean makeNewWhenEmpty) { - // append WHERE to can use MRole.getDefault().addAccessSQL - String sqlWhere = " WHERE AD_Table_ID=? AND IsTableBased='Y' "; + String constantForRoleAccess = "SELECT * FROM AD_PrintFormat WHERE "; + StringBuilder sqlWhereB = new StringBuilder(constantForRoleAccess) + .append("AD_Table_ID=? AND IsTableBased='Y' "); if (AD_Window_ID > 0) - sqlWhere += "AND (AD_Window_ID=? OR AD_Window_ID IS NULL) "; + sqlWhereB.append("AND (AD_Window_ID=? OR AD_Window_ID IS NULL)"); // - sqlWhere = MRole.getDefault().addAccessSQL ( - sqlWhere, "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - + String sqlWhere = MRole.getDefault().addAccessSQL ( + sqlWhereB.toString(), "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); + // remove " WHERE " to use in Query - sqlWhere = sqlWhere.substring(6); + sqlWhere = sqlWhere.substring(constantForRoleAccess.length()); // add sql parameter List lsParameter = new ArrayList(); - + lsParameter.add(new Integer(AD_Table_ID)); - if (AD_Window_ID > 0) + if (AD_Window_ID > 0) lsParameter.add(new Integer(AD_Window_ID)); // init query