From 9ddf2464528fe3f9828747ddab3f6a874f05a49a Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 8 May 2015 12:35:48 -0500 Subject: [PATCH 1/7] IDEMPIERE-2611 Error no refresh after delete --- .../org/adempiere/webui/adwindow/AbstractADWindowContent.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index e8aba39a00..ca0fb0a955 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -2321,6 +2321,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements { //error will be catch in the dataStatusChanged event adTabbox.getSelectedGridTab().dataDelete(); + adTabbox.getSelectedGridTab().dataRefreshAll(true, true); adTabbox.getSelectedGridTab().refreshParentTabs(); adTabbox.getSelectedTabpanel().dynamicDisplay(0); @@ -2365,6 +2366,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements count++; } } + adTabbox.getSelectedGridTab().dataRefreshAll(true, true); adTabbox.getSelectedGridTab().refreshParentTabs(); adTabbox.getSelectedTabpanel().dynamicDisplay(0); From ac460b523af6f61254e86c7c6e101a2db9ef670c Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 13 May 2015 11:18:09 -0500 Subject: [PATCH 2/7] IDEMPIERE-2605 Bypass Product Qty checks/warnings in CalloutOrder when order is DropShip / based on patch from Carlin Reed (creed.gds) --- .../src/org/compiere/model/CalloutOrder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index 515ab3419c..7405e8f07f 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -837,7 +837,7 @@ public class CalloutOrder extends CalloutEngine if (Env.isSOTrx(ctx, WindowNo)) { MProduct product = MProduct.get (ctx, M_Product_ID.intValue()); - if (product.isStocked()) + if (product.isStocked() && Env.getContext(ctx, WindowNo, "IsDropShip").equals("N")) { BigDecimal QtyOrdered = (BigDecimal)mTab.getValue("QtyOrdered"); int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID"); @@ -1324,7 +1324,7 @@ public class CalloutOrder extends CalloutEngine && QtyOrdered.signum() > 0) // no negative (returns) { MProduct product = MProduct.get (ctx, M_Product_ID); - if (product.isStocked()) + if (product.isStocked() && Env.getContext(ctx, WindowNo, "IsDropShip").equals("N")) { int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID"); int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "M_AttributeSetInstance_ID"); From cc72307e7197a0153503959ac98d6e40a9928936 Mon Sep 17 00:00:00 2001 From: Deepak Pansheriya Date: Tue, 12 May 2015 11:04:22 +0530 Subject: [PATCH 3/7] IDEMPIERE-2564 Taking DateMPolicy from Storage --- .../src/org/compiere/model/MMovement.java | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MMovement.java b/org.adempiere.base/src/org/compiere/model/MMovement.java index 31bc0ef42f..a85bc9f60a 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovement.java +++ b/org.adempiere.base/src/org/compiere/model/MMovement.java @@ -474,26 +474,71 @@ public class MMovement extends X_M_Movement implements DocAction // Fallback - We have ASI if (trxFrom == null) { + Timestamp dateMPolicy= null; + + MStorageOnHand[] storages = null; + if (line.getMovementQty().compareTo(Env.ZERO) > 0) { + // Find Date Material Policy bases on ASI + storages = MStorageOnHand.getWarehouse(getCtx(), 0, + line.getM_Product_ID(), line + .getM_AttributeSetInstance_ID(), null, + MClient.MMPOLICY_FiFo.equals(product + .getMMPolicy()), false, line + .getM_Locator_ID(), get_TrxName()); + } + else{ + //Case of reversal + storages = MStorageOnHand + .getWarehouse(getCtx(), 0, line.getM_Product_ID(), + line.getM_AttributeSetInstanceTo_ID(), null, + MClient.MMPOLICY_FiFo.equals(product + .getMMPolicy()), false, line + .getM_LocatorTo_ID(), get_TrxName()); + } + for (MStorageOnHand storage : storages) { + if (storage.getQtyOnHand().compareTo( + line.getMovementQty()) >= 0) { + dateMPolicy = storage.getDateMaterialPolicy(); + break; + } + } + + if (dateMPolicy == null && storages.length > 0) + dateMPolicy = storages[0].getDateMaterialPolicy(); + + if(dateMPolicy==null && line.getM_AttributeSetInstanceTo_ID()!=0){ + I_M_AttributeSetInstance asi = line.getM_AttributeSetInstance(); + dateMPolicy = asi.getCreated(); + } + else if(dateMPolicy==null ) + dateMPolicy = getMovementDate(); + MLocator locator = new MLocator (getCtx(), line.getM_Locator_ID(), get_TrxName()); //Update Storage if (!MStorageOnHand.add(getCtx(),locator.getM_Warehouse_ID(), line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), - line.getMovementQty().negate(), null, get_TrxName())) + line.getMovementQty().negate(),dateMPolicy, get_TrxName())) { String lastError = CLogger.retrieveErrorString(""); m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError; return DocAction.STATUS_Invalid; } + //TO may have Different material policy + I_M_AttributeSetInstance asiTo = line.getM_AttributeSetInstanceTo(); + Timestamp dateMPolicyTo= null; + + + //Update Storage MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName()); if (!MStorageOnHand.add(getCtx(),locatorTo.getM_Warehouse_ID(), line.getM_LocatorTo_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstanceTo_ID(), - line.getMovementQty(), null, get_TrxName())) + line.getMovementQty(),dateMPolicy, get_TrxName())) { String lastError = CLogger.retrieveErrorString(""); m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError; From 758ef67e76255148905818ab9d6da5a1d9de9562 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 13 May 2015 17:47:35 -0500 Subject: [PATCH 4/7] IDEMPIERE-2564 / IDEMPIERE-2615 Date Material Policy not respected in movement / peer review --- .../src/org/compiere/model/MMovement.java | 38 ++++++------------- .../org/compiere/model/MStorageOnHand.java | 2 +- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MMovement.java b/org.adempiere.base/src/org/compiere/model/MMovement.java index a85bc9f60a..1ad6d522e2 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovement.java +++ b/org.adempiere.base/src/org/compiere/model/MMovement.java @@ -475,29 +475,22 @@ public class MMovement extends X_M_Movement implements DocAction if (trxFrom == null) { Timestamp dateMPolicy= null; - MStorageOnHand[] storages = null; if (line.getMovementQty().compareTo(Env.ZERO) > 0) { // Find Date Material Policy bases on ASI storages = MStorageOnHand.getWarehouse(getCtx(), 0, - line.getM_Product_ID(), line - .getM_AttributeSetInstance_ID(), null, - MClient.MMPOLICY_FiFo.equals(product - .getMMPolicy()), false, line - .getM_Locator_ID(), get_TrxName()); - } - else{ + line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), null, + MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false, + line.getM_Locator_ID(), get_TrxName()); + } else { //Case of reversal - storages = MStorageOnHand - .getWarehouse(getCtx(), 0, line.getM_Product_ID(), - line.getM_AttributeSetInstanceTo_ID(), null, - MClient.MMPOLICY_FiFo.equals(product - .getMMPolicy()), false, line - .getM_LocatorTo_ID(), get_TrxName()); + storages = MStorageOnHand.getWarehouse(getCtx(), 0, + line.getM_Product_ID(), line.getM_AttributeSetInstanceTo_ID(), null, + MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false, + line.getM_LocatorTo_ID(), get_TrxName()); } for (MStorageOnHand storage : storages) { - if (storage.getQtyOnHand().compareTo( - line.getMovementQty()) >= 0) { + if (storage.getQtyOnHand().compareTo(line.getMovementQty()) >= 0) { dateMPolicy = storage.getDateMaterialPolicy(); break; } @@ -506,13 +499,12 @@ public class MMovement extends X_M_Movement implements DocAction if (dateMPolicy == null && storages.length > 0) dateMPolicy = storages[0].getDateMaterialPolicy(); - if(dateMPolicy==null && line.getM_AttributeSetInstanceTo_ID()!=0){ + if (dateMPolicy==null && line.getM_AttributeSetInstanceTo_ID()!=0) { I_M_AttributeSetInstance asi = line.getM_AttributeSetInstance(); dateMPolicy = asi.getCreated(); - } - else if(dateMPolicy==null ) + } else if(dateMPolicy==null) dateMPolicy = getMovementDate(); - + MLocator locator = new MLocator (getCtx(), line.getM_Locator_ID(), get_TrxName()); //Update Storage if (!MStorageOnHand.add(getCtx(),locator.getM_Warehouse_ID(), @@ -526,12 +518,6 @@ public class MMovement extends X_M_Movement implements DocAction return DocAction.STATUS_Invalid; } - //TO may have Different material policy - I_M_AttributeSetInstance asiTo = line.getM_AttributeSetInstanceTo(); - Timestamp dateMPolicyTo= null; - - - //Update Storage MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName()); if (!MStorageOnHand.add(getCtx(),locatorTo.getM_Warehouse_ID(), diff --git a/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java b/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java index 4f0e00b5b6..0a80755095 100644 --- a/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java +++ b/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java @@ -324,7 +324,7 @@ public class MStorageOnHand extends X_M_StorageOnHand // Specific Attribute Set Instance String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID," + "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy," - + "s.QtyOnHand,s.DateLastInventory,s.DateMaterialPolicy " + + "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy " + "FROM M_StorageOnHand s" + " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) "; if (M_Locator_ID > 0) From bd0ad9a71a88940017b19db147df4a344083fee3 Mon Sep 17 00:00:00 2001 From: Diego Ruiz Date: Wed, 13 May 2015 18:17:15 -0500 Subject: [PATCH 5/7] IDEMPIERE-2181 Lookup fields when in detail pane --- .../src/org/compiere/model/GridFieldVO.java | 2 +- .../src/org/compiere/model/MLookup.java | 2 +- .../org/compiere/model/MLookupFactory.java | 77 ++++++++++++++++ .../src/org/compiere/model/MLookupInfo.java | 4 +- .../src/org/compiere/util/Env.java | 88 +++++++++++++++++++ 5 files changed, 170 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java index 6f9accc26b..83bc5ecc40 100644 --- a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java @@ -683,7 +683,7 @@ public class GridFieldVO implements Serializable public void loadLookupInfo() { try { - lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, AD_Column_ID, displayType, + lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, TabNo,AD_Column_ID, displayType, Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID, IsParent, ValidationCode); if (lookupInfo == null) diff --git a/org.adempiere.base/src/org/compiere/model/MLookup.java b/org.adempiere.base/src/org/compiere/model/MLookup.java index f5d2940b51..c54d55ac29 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLookup.java @@ -742,7 +742,7 @@ public final class MLookup extends Lookup implements Serializable // not validated if (!m_info.IsValidated) { - String validation = Env.parseContext(m_info.ctx, m_info.WindowNo, m_info.ValidationCode, false); + String validation = Env.parseContext(m_info.ctx, m_info.WindowNo, m_info.tabNo, m_info.ValidationCode, false); m_info.parsedValidationCode = validation; if (validation.length() == 0 && m_info.ValidationCode.length() > 0) { diff --git a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java index 9a8cd9f388..7dd1438ade 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java @@ -129,6 +129,52 @@ public class MLookupFactory return info; } + + public static MLookupInfo getLookupInfo(Properties ctx, int WindowNo, int TabNo, int Column_ID, int AD_Reference_ID) + { + String ColumnName = ""; + int AD_Reference_Value_ID = 0; + boolean IsParent = false; + String ValidationCode = ""; + // + String sql = "SELECT c.ColumnName, c.AD_Reference_Value_ID, c.IsParent, vr.Code " + + "FROM AD_Column c" + + " LEFT OUTER JOIN AD_Val_Rule vr ON (c.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) " + + "WHERE c.AD_Column_ID=?"; + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement(sql, null); + pstmt.setInt(1, Column_ID); + // + rs = pstmt.executeQuery(); + if (rs.next()) + { + ColumnName = rs.getString(1); + AD_Reference_Value_ID = rs.getInt(2); + IsParent = "Y".equals(rs.getString(3)); + ValidationCode = rs.getString(4); + } + else + s_log.log(Level.SEVERE, "Column Not Found - AD_Column_ID=" + Column_ID); + } + catch (SQLException ex) + { + s_log.log(Level.SEVERE, "create", ex); + } + finally + { + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + // + MLookupInfo info = getLookupInfo (ctx, WindowNo, TabNo, Column_ID, AD_Reference_ID, + Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID, IsParent, ValidationCode); + + return info; + } /** * Create MLookup @@ -170,6 +216,36 @@ public class MLookupFactory int Column_ID, int AD_Reference_ID, Language language, String ColumnName, int AD_Reference_Value_ID, boolean IsParent, String ValidationCode) + { + return getLookupInfo(ctx, WindowNo, 0, + Column_ID, AD_Reference_ID, + language, ColumnName, AD_Reference_Value_ID, + IsParent, ValidationCode); + } // createLookupInfo + + /************************************************************************** + * Get Information for Lookups based on Column_ID for Table Columns or Process Parameters. + * + * The SQL returns three columns: + *
+	 *		Key, Value, Name, IsActive	(where either key or value is null)
+	 *  
+ * @param ctx context for access + * @param language report language + * @param WindowNo window no + * @param tabNo tab no + * @param Column_ID AD_Column_ID or AD_Process_Para_ID + * @param ColumnName key column name + * @param AD_Reference_ID display type + * @param AD_Reference_Value_ID AD_Reference (List, Table) + * @param IsParent parent (prevents query to directly access value) + * @param ValidationCode optional SQL validation + * @return lookup info structure + */ + static public MLookupInfo getLookupInfo (Properties ctx, int WindowNo, int tabNo, + int Column_ID, int AD_Reference_ID, + Language language, String ColumnName, int AD_Reference_Value_ID, + boolean IsParent, String ValidationCode) { MLookupInfo info = null; boolean needToAddSecurity = true; @@ -199,6 +275,7 @@ public class MLookupFactory // remaining values info.ctx = ctx; info.WindowNo = WindowNo; + info.tabNo = tabNo; info.Column_ID = Column_ID; info.DisplayType = AD_Reference_ID; info.AD_Reference_Value_ID = AD_Reference_Value_ID; diff --git a/org.adempiere.base/src/org/compiere/model/MLookupInfo.java b/org.adempiere.base/src/org/compiere/model/MLookupInfo.java index 530c3b0639..800a296232 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupInfo.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupInfo.java @@ -160,7 +160,7 @@ public class MLookupInfo implements Serializable, Cloneable ZoomQuery = zoomQuery; } // MLookupInfo - static final long serialVersionUID = -7958664359250070233L; + static final long serialVersionUID = -1869207615748248653L; /** SQL Query */ public String Query = null; @@ -190,6 +190,8 @@ public class MLookupInfo implements Serializable, Cloneable public Properties ctx = null; /** WindowNo */ public int WindowNo; + /** TabNo */ + public int tabNo; /** AD_Column_Info or AD_Process_Para */ public int Column_ID; diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index cb16c61577..c4fb04a588 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -1421,6 +1421,78 @@ public final class Env return outStr.toString(); } // parseContext + + /** + * Parse Context replaces global or Window context @tag@ with actual value. + * + * @tag@ are ignored otherwise "" is returned + * @param ctx context + * @param WindowNo Number of Window + * @param tabNo Number of Tab + * @param value Message to be parsed + * @param onlyTab if true, no defaults are used + * @param ignoreUnparsable if true, unsuccessful @return parsed String or "" if not successful and ignoreUnparsable + * @return parsed context + */ + public static String parseContext (Properties ctx, int WindowNo, int tabNo, String value, + boolean onlyTab, boolean ignoreUnparsable) + { + if (value == null || value.length() == 0) + return ""; + + String token; + String inStr = new String(value); + StringBuilder outStr = new StringBuilder(); + + int i = inStr.indexOf('@'); + while (i != -1) + { + outStr.append(inStr.substring(0, i)); // up to @ + inStr = inStr.substring(i+1, inStr.length()); // from first @ + + int j = inStr.indexOf('@'); // next @ + if (j < 0) + { + if (log.isLoggable(Level.INFO)) log.log(Level.INFO, "No second tag: " + inStr); + //not context variable, add back @ and break + outStr.append("@"); + break; + } + + token = inStr.substring(0, j); + + // IDEMPIERE-194 Handling null context variable + String defaultV = null; + int idx = token.indexOf(":"); // or clause + if (idx >= 0) + { + defaultV = token.substring(idx+1, token.length()); + token = token.substring(0, idx); + } + + String ctxInfo = getContext(ctx, WindowNo, tabNo, token, onlyTab); // get context + if (ctxInfo.length() == 0 && (token.startsWith("#") || token.startsWith("$")) ) + ctxInfo = getContext(ctx, token); // get global context + + if (ctxInfo.length() == 0 && defaultV != null) + ctxInfo = defaultV; + + if (ctxInfo.length() == 0) + { + if (log.isLoggable(Level.CONFIG)) log.config("No Context Win=" + WindowNo + " for: " + token); + if (!ignoreUnparsable) + return ""; // token not found + } + else + outStr.append(ctxInfo); // replace context with Context + + inStr = inStr.substring(j+1, inStr.length()); // from second @ + i = inStr.indexOf('@'); + } + outStr.append(inStr); // add the rest of the string + + return outStr.toString(); + } // parseContext /** * Parse Context replaces global or Window context @tag@ with actual value. @@ -1436,6 +1508,22 @@ public final class Env { return parseContext(ctx, WindowNo, value, onlyWindow, false); } // parseContext + + /** + * Parse Context replaces global or Window context @tag@ with actual value. + * + * @param ctx context + * @param WindowNo Number of Window + * @param TabNo Number of Tab + * @param value Message to be parsed + * @param onlyWindow if true, no defaults are used + * @return parsed String or "" if not successful + */ + public static String parseContext (Properties ctx, int WindowNo, int tabNo, String value, + boolean onlyWindow) + { + return parseContext(ctx, WindowNo, tabNo, value, onlyWindow, false); + } // parseContext /** * Parse expression, replaces global or PO properties @tag@ with actual value. From ffd2288dfd0cff09734b92ab6bc3bfb913eb2a6f Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 13 May 2015 18:18:54 -0500 Subject: [PATCH 6/7] IDEMPIERE-2181 Lookup fields when in detail pane / peer review --- .../src/org/compiere/model/GridFieldVO.java | 2 +- .../org/compiere/model/MLookupFactory.java | 49 ++----------------- .../src/org/compiere/util/Env.java | 3 +- 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java index 83bc5ecc40..3c868ea433 100644 --- a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java @@ -683,7 +683,7 @@ public class GridFieldVO implements Serializable public void loadLookupInfo() { try { - lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, TabNo,AD_Column_ID, displayType, + lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, TabNo, AD_Column_ID, displayType, Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID, IsParent, ValidationCode); if (lookupInfo == null) diff --git a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java index 7dd1438ade..0a705da80c 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java @@ -86,48 +86,7 @@ public class MLookupFactory public static MLookupInfo getLookupInfo(Properties ctx, int WindowNo, int Column_ID, int AD_Reference_ID) { - String ColumnName = ""; - int AD_Reference_Value_ID = 0; - boolean IsParent = false; - String ValidationCode = ""; - // - String sql = "SELECT c.ColumnName, c.AD_Reference_Value_ID, c.IsParent, vr.Code " - + "FROM AD_Column c" - + " LEFT OUTER JOIN AD_Val_Rule vr ON (c.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) " - + "WHERE c.AD_Column_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, Column_ID); - // - rs = pstmt.executeQuery(); - if (rs.next()) - { - ColumnName = rs.getString(1); - AD_Reference_Value_ID = rs.getInt(2); - IsParent = "Y".equals(rs.getString(3)); - ValidationCode = rs.getString(4); - } - else - s_log.log(Level.SEVERE, "Column Not Found - AD_Column_ID=" + Column_ID); - } - catch (SQLException ex) - { - s_log.log(Level.SEVERE, "create", ex); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - // - MLookupInfo info = getLookupInfo (ctx, WindowNo, Column_ID, AD_Reference_ID, - Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID, IsParent, ValidationCode); - - return info; + return getLookupInfo(ctx, WindowNo, 0, Column_ID, AD_Reference_ID); } public static MLookupInfo getLookupInfo(Properties ctx, int WindowNo, int TabNo, int Column_ID, int AD_Reference_ID) @@ -189,7 +148,7 @@ public class MLookupFactory public static MLookup get (Properties ctx, int WindowNo, int TabNo, int Column_ID, int AD_Reference_ID) { // - MLookupInfo info = getLookupInfo (ctx, WindowNo, Column_ID, AD_Reference_ID); + MLookupInfo info = getLookupInfo (ctx, WindowNo, TabNo, Column_ID, AD_Reference_ID); return new MLookup(info, TabNo); } // get @@ -221,7 +180,7 @@ public class MLookupFactory Column_ID, AD_Reference_ID, language, ColumnName, AD_Reference_Value_ID, IsParent, ValidationCode); - } // createLookupInfo + } // getLookupInfo /************************************************************************** * Get Information for Lookups based on Column_ID for Table Columns or Process Parameters. @@ -348,7 +307,7 @@ public class MLookupFactory // s_log.finest("Query: " + info.Query); // s_log.finest("Direct: " + info.QueryDirect); return info; - } // createLookupInfo + } // getLookupInfo /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index c4fb04a588..7656bffacc 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -593,8 +593,7 @@ public final class Env */ public static String getContext (Properties ctx, int WindowNo, int TabNo, String context, boolean onlyTab) { - final boolean onlyWindow = onlyTab ? true : false; - return getContext(ctx, WindowNo, TabNo, context, onlyTab, onlyWindow); + return getContext(ctx, WindowNo, TabNo, context, onlyTab, onlyTab); } /** From 15a7173e648a09c07c7918471c73ea83b5fc28b9 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 13 May 2015 18:47:50 -0500 Subject: [PATCH 7/7] IDEMPIERE-2596 Lost changes when attachment window is closed / avoid NPE and duplicated process of changes --- .../adempiere/webui/panel/WAttachment.java | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java index d61c8f0998..e9eb19e3db 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java @@ -478,28 +478,31 @@ public class WAttachment extends Window implements EventListener UploadEvent ue = (UploadEvent) e; processUploadMedia(ue.getMedia()); } else if (e.getTarget() == bOk || DialogEvents.ON_WINDOW_CLOSE.equals(e.getName())) { - String newText = text.getText(); - if (newText == null) - newText = ""; - String oldText = m_attachment.getTextMsg(); - if (oldText == null) - oldText = ""; + if (m_attachment != null) { + String newText = text.getText(); + if (newText == null) + newText = ""; + String oldText = m_attachment.getTextMsg(); + if (oldText == null) + oldText = ""; - if (!m_change) - m_change = !newText.equals(oldText); + if (!m_change) + m_change = !newText.equals(oldText); - if (newText.length() > 0 || m_attachment.getEntryCount() > 0) { - if (m_change) { - m_attachment.setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :( - m_attachment.setTextMsg(text.getText()); - m_attachment.saveEx(); + if (newText.length() > 0 || m_attachment.getEntryCount() > 0) { + if (m_change) { + m_attachment.setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :( + m_attachment.setTextMsg(text.getText()); + m_attachment.saveEx(); + m_change = false; + } + } else { + m_attachment.delete(true); + m_attachment = null; } - } else { - m_attachment.delete(true); - m_attachment = null; - } - dispose(); + dispose(); + } } else if (e.getTarget() == bCancel) { // Cancel dispose();