diff --git a/org.adempiere.base/src/org/compiere/model/MLookup.java b/org.adempiere.base/src/org/compiere/model/MLookup.java index 1e91095c6a..f5d2940b51 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLookup.java @@ -575,7 +575,7 @@ public final class MLookup extends Lookup implements Serializable if (m_info.ZoomWindowPO == 0 || query == null) return m_info.ZoomWindow; // Need to check SO/PO - boolean isSOTrx = DB.isSOTrx(m_info.TableName, query.getWhereClause(false)); + boolean isSOTrx = DB.isSOTrx(m_info.TableName, query.getWhereClause(false), m_info.WindowNo); // return getZoom(isSOTrx); } // getZoom diff --git a/org.adempiere.base/src/org/compiere/util/DB.java b/org.adempiere.base/src/org/compiere/util/DB.java index f3078b7920..92bf1b6628 100644 --- a/org.adempiere.base/src/org/compiere/util/DB.java +++ b/org.adempiere.base/src/org/compiere/util/DB.java @@ -1695,9 +1695,10 @@ public final class DB * Assumes Sales Order. Queries IsSOTrx of table with where clause * @param TableName table * @param whereClause where clause + * @param windowNo * @return true (default) or false if tested that not SO */ - public static boolean isSOTrx (String TableName, String whereClause) + public static boolean isSOTrx (String TableName, String whereClause, int windowNo) { if (TableName == null || TableName.length() == 0) { @@ -1710,7 +1711,7 @@ public final class DB return true; } // - boolean isSOTrx = true; + Boolean isSOTrx = null; boolean noIsSOTrxColumn = false; if (MTable.get(Env.getCtx(), TableName).getColumn("IsSOTrx") == null) { noIsSOTrxColumn = true; @@ -1724,7 +1725,7 @@ public final class DB pstmt = DB.prepareStatement (sql, null); rs = pstmt.executeQuery (); if (rs.next ()) - isSOTrx = "Y".equals(rs.getString(1)); + isSOTrx = Boolean.valueOf("Y".equals(rs.getString(1))); } catch (Exception e) { @@ -1754,7 +1755,7 @@ public final class DB pstmt2 = DB.prepareStatement (sql, null); rs2 = pstmt2.executeQuery (); if (rs2.next ()) - isSOTrx = "Y".equals(rs2.getString(1)); + isSOTrx = Boolean.valueOf("Y".equals(rs2.getString(1))); } catch (Exception ee) { @@ -1770,9 +1771,20 @@ public final class DB } if (noIsSOTrxColumn) if (log.isLoggable(Level.FINEST))log.log(Level.FINEST, TableName + " - No SOTrx"); - return isSOTrx; + if (isSOTrx == null) { + if (windowNo >= 0) { + // check context + isSOTrx = Boolean.valueOf("Y".equals(Env.getContext(Env.getCtx(), windowNo, "IsSOTrx"))); + } else { + isSOTrx = Boolean.TRUE; + } + } + return isSOTrx.booleanValue(); } // isSOTrx + public static boolean isSOTrx (String TableName, String whereClause) { + return isSOTrx (TableName, whereClause, -1); + } /************************************************************************** * Get next number for Key column = 0 is Error. diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index 5e3fd5f7d4..a57e4a6d2c 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -1874,7 +1874,7 @@ public final class Env if (table.getPO_Window_ID() != 0) { String whereClause = table.getTableName() + "_ID=" + Record_ID; - isSOTrx = DB.isSOTrx(table.getTableName(), whereClause); + isSOTrx = DB.isSOTrx(table.getTableName(), whereClause, windowNo); if (!isSOTrx) AD_Window_ID = table.getPO_Window_ID(); }