Revert rev 12032 6140 02c37e74eefd - Implemented patch solves a critical problem, but open a new one

this means this bug is still open in swing and zkwebui, but requires a better approach to solve it:
BF [2987605] - Attribute Set Instance dialog: select existing ASI
This commit is contained in:
Carlos Ruiz 2011-02-26 22:37:11 -05:00
parent 4e143f09f2
commit db838952ba
2 changed files with 31 additions and 38 deletions

View File

@ -74,7 +74,7 @@ public class PAttributeInstance extends CDialog
super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true); super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true);
init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID); init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID);
AEnv.showCenterWindow(parent, this); AEnv.showCenterWindow(parent, this);
} } // PAttributeInstance
/** /**
* Constructor * Constructor
@ -91,7 +91,7 @@ public class PAttributeInstance extends CDialog
super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true); super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true);
init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID); init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID);
AEnv.showCenterWindow(parent, this); AEnv.showCenterWindow(parent, this);
} } // PAttributeInstance
/** /**
* Initialization * Initialization
@ -117,7 +117,7 @@ public class PAttributeInstance extends CDialog
{ {
log.log(Level.SEVERE, "", e); log.log(Level.SEVERE, "", e);
} }
} } // init
private CPanel mainPanel = new CPanel(); private CPanel mainPanel = new CPanel();
private BorderLayout mainLayout = new BorderLayout(); private BorderLayout mainLayout = new BorderLayout();
@ -158,19 +158,17 @@ public class PAttributeInstance extends CDialog
// South // South
mainPanel.add(confirmPanel, BorderLayout.SOUTH); mainPanel.add(confirmPanel, BorderLayout.SOUTH);
confirmPanel.addActionListener(this); confirmPanel.addActionListener(this);
} } // jbInit
/** Table Column Layout Info */ /** Table Column Layout Info */
private static ColumnInfo[] s_layout = new ColumnInfo[] private static ColumnInfo[] s_layout = new ColumnInfo[]
{ {
new ColumnInfo(" ", "asi.M_AttributeSetInstance_ID", IDColumn.class), new ColumnInfo(" ", "s.M_AttributeSetInstance_ID", IDColumn.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "asi.Description", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "asi.Description", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Lot"), "asi.Lot", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Lot"), "asi.Lot", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "SerNo"), "asi.SerNo", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "SerNo"), "asi.SerNo", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "GuaranteeDate"), "asi.GuaranteeDate", Timestamp.class), new ColumnInfo(Msg.translate(Env.getCtx(), "GuaranteeDate"), "asi.GuaranteeDate", Timestamp.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "M_Locator_ID"), "l.Value", KeyNamePair.class, "s.M_Locator_ID"), new ColumnInfo(Msg.translate(Env.getCtx(), "M_Locator_ID"), "l.Value", KeyNamePair.class, "s.M_Locator_ID"),
// new ColumnInfo(Msg.translate(Env.getCtx(), "M_Product_ID"), "p.Value", KeyNamePair.class, "p.M_Product_ID"), // @Trifon - Not sure if this need to be shown
// new ColumnInfo(Msg.translate(Env.getCtx(), "M_AttributeSet_ID"), "st.Name", KeyNamePair.class, "st.M_AttributeSet_ID"), // @Trifon - Not sure if this need to be shown
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "s.QtyOnHand", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "s.QtyOnHand", Double.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "s.QtyReserved", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "s.QtyReserved", Double.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "s.QtyOrdered", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "s.QtyOrdered", Double.class),
@ -180,16 +178,13 @@ public class PAttributeInstance extends CDialog
new ColumnInfo(Msg.translate(Env.getCtx(), "ShelfLifeRemainingPct"), "CASE WHEN p.GuaranteeDays > 0 THEN TRUNC(((daysbetween(asi.GuaranteeDate, SYSDATE))/p.GuaranteeDays)*100) ELSE 0 END", Integer.class), new ColumnInfo(Msg.translate(Env.getCtx(), "ShelfLifeRemainingPct"), "CASE WHEN p.GuaranteeDays > 0 THEN TRUNC(((daysbetween(asi.GuaranteeDate, SYSDATE))/p.GuaranteeDays)*100) ELSE 0 END", Integer.class),
}; };
/** From Clause */ /** From Clause */
private static String s_sqlFrom = "M_AttributeSetInstance asi" private static String s_sqlFrom = "M_Storage s"
+ " INNER JOIN M_AttributeSet st ON (st.M_AttributeSet_ID=asi.M_AttributeSet_ID )" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)"
+ " LEFT OUTER JOIN M_Storage s ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)" + " INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)"
+ " LEFT OUTER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)";
+ " LEFT OUTER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)"
+ " LEFT OUTER JOIN M_Product pr ON (asi.M_AttributeSet_ID = pr.M_AttributeSet_ID)"
;
/** Where Clause */ /** Where Clause */
private static String s_sqlWhereWithoutWarehouse = " (pr.M_Product_ID=? OR p.M_Product_ID=?)"; private static String s_sqlWhere = "s.M_Product_ID=? AND l.M_Warehouse_ID=?";
private static String s_sqlWhereSameWarehouse = " AND (l.M_Warehouse_ID=? OR 0=?)"; private static String s_sqlWhereWithoutWarehouse = " s.M_Product_ID=?";
private String m_sqlNonZero = " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)"; private String m_sqlNonZero = " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)";
private String m_sqlMinLife = ""; private String m_sqlMinLife = "";
@ -247,7 +242,8 @@ public class PAttributeInstance extends CDialog
} }
} // BPartner != 0 } // BPartner != 0
m_sql = m_table.prepareTable (s_layout, s_sqlFrom, s_sqlWhereWithoutWarehouse, false, "asi") m_sql = m_table.prepareTable (s_layout, s_sqlFrom,
m_M_Warehouse_ID == 0 ? s_sqlWhereWithoutWarehouse : s_sqlWhere, false, "s")
+ " ORDER BY asi.GuaranteeDate, s.QtyOnHand"; // oldest, smallest first + " ORDER BY asi.GuaranteeDate, s.QtyOnHand"; // oldest, smallest first
// //
m_table.setRowSelectionAllowed(true); m_table.setRowSelectionAllowed(true);
@ -256,7 +252,7 @@ public class PAttributeInstance extends CDialog
m_table.getSelectionModel().addListSelectionListener(this); m_table.getSelectionModel().addListSelectionListener(this);
// //
refresh(); refresh();
} } // dynInit
/** /**
* Refresh Query * Refresh Query
@ -268,7 +264,7 @@ public class PAttributeInstance extends CDialog
if (!showAll.isSelected()) if (!showAll.isSelected())
{ {
sql = m_sql.substring(0, pos) sql = m_sql.substring(0, pos)
+ m_sqlNonZero + s_sqlWhereSameWarehouse; + m_sqlNonZero;
if (m_sqlMinLife.length() > 0) if (m_sqlMinLife.length() > 0)
sql += m_sqlMinLife; sql += m_sqlMinLife;
sql += m_sql.substring(pos); sql += m_sql.substring(pos);
@ -281,12 +277,8 @@ public class PAttributeInstance extends CDialog
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(1, m_M_Product_ID);
pstmt.setInt(2, m_M_Product_ID); if (m_M_Warehouse_ID != 0)
if ( !showAll.isSelected() ) { pstmt.setInt(2, m_M_Warehouse_ID);
pstmt.setInt(3, m_M_Warehouse_ID);
pstmt.setInt(4, m_M_Warehouse_ID);
}
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
m_table.loadTable(rs); m_table.loadTable(rs);
} }
@ -299,7 +291,7 @@ public class PAttributeInstance extends CDialog
rs = null; pstmt = null; rs = null; pstmt = null;
} }
enableButtons(); enableButtons();
} } // refresh
/** /**
* Action Listener * Action Listener
@ -319,7 +311,7 @@ public class PAttributeInstance extends CDialog
{ {
refresh(); refresh();
} }
} } // actionPerformed
/** /**
* Table selection changed * Table selection changed
@ -330,7 +322,7 @@ public class PAttributeInstance extends CDialog
if (e.getValueIsAdjusting()) if (e.getValueIsAdjusting())
return; return;
enableButtons(); enableButtons();
} } // valueChanged
/** /**
* Enable/Set Buttons and set ID * Enable/Set Buttons and set ID
@ -362,7 +354,7 @@ public class PAttributeInstance extends CDialog
log.fine("M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID log.fine("M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID
+ " - " + m_M_AttributeSetInstanceName + " - " + m_M_AttributeSetInstanceName
+ "; M_Locator_ID=" + m_M_Locator_ID); + "; M_Locator_ID=" + m_M_Locator_ID);
} } // enableButtons
/** /**
* Mouse Clicked * Mouse Clicked
@ -376,7 +368,7 @@ public class PAttributeInstance extends CDialog
enableButtons(); enableButtons();
dispose(); dispose();
} }
} } // mouseClicked
/** /**
@ -386,7 +378,7 @@ public class PAttributeInstance extends CDialog
public int getM_AttributeSetInstance_ID() public int getM_AttributeSetInstance_ID()
{ {
return m_M_AttributeSetInstance_ID; return m_M_AttributeSetInstance_ID;
} } // getM_AttributeSetInstance_ID
/** /**
* Get Instance Name * Get Instance Name
@ -395,7 +387,7 @@ public class PAttributeInstance extends CDialog
public String getM_AttributeSetInstanceName() public String getM_AttributeSetInstanceName()
{ {
return m_M_AttributeSetInstanceName; return m_M_AttributeSetInstanceName;
} } // getM_AttributeSetInstanceName
/** /**
* Get Locator * Get Locator
@ -404,6 +396,6 @@ public class PAttributeInstance extends CDialog
public int getM_Locator_ID() public int getM_Locator_ID()
{ {
return m_M_Locator_ID; return m_M_Locator_ID;
} } // getM_Locator_ID
} } // PAttributeInstance

View File

@ -599,9 +599,10 @@ public class VPAttributeDialog extends CDialog
} }
// teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes // teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes
// Trifon - Always read Locator from Context. There are too many windows to read explicitly one by one.
int M_Locator_ID = 0; int M_Locator_ID = 0;
if (m_AD_Column_ID == 8551) { // TODO: hardcoded: M_MovementLine[324].M_AttributeSetInstance_ID[8551]
M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true); // only window M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true); // only window
}
String title = ""; String title = "";
// Get Text // Get Text
@ -617,7 +618,7 @@ public class VPAttributeDialog extends CDialog
pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID); pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
title = ": " + rs.getString(1) + " - " + rs.getString(2); title = rs.getString(1) + " - " + rs.getString(2);
M_Warehouse_ID = rs.getInt(3); // fetch the actual warehouse - teo_sarca [ 1564520 ] M_Warehouse_ID = rs.getInt(3); // fetch the actual warehouse - teo_sarca [ 1564520 ]
} }
} }