Accepted slightly modified fix from Suzanne Calderon [ 1879091 ] Material receipt with attribute set instance incomplete

This commit is contained in:
Carlos Ruiz 2008-01-24 20:19:21 +00:00
parent 9667f26ad9
commit fd1fed9aa2
2 changed files with 21 additions and 11 deletions

View File

@ -22,7 +22,6 @@ import java.sql.*;
import java.util.logging.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import org.compiere.apps.*;
import org.compiere.minigrid.*;
import org.compiere.swing.*;
@ -107,7 +106,6 @@ public class PAttributeInstance extends CDialog
private CCheckBox showAll = new CCheckBox (Msg.getMsg(Env.getCtx(), "ShowAll"));
//
private MiniTable m_table = new MiniTable();
private DefaultTableModel m_model;
// Parameter
private int m_M_Warehouse_ID;
private int m_M_Locator_ID;
@ -163,7 +161,8 @@ public class PAttributeInstance extends CDialog
+ " INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)"
+ " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)";
/** Where Clause */
private static String s_sqlWhere = "l.M_Warehouse_ID=? AND s.M_Product_ID=?";
private static String s_sqlWhere = "s.M_Product_ID=? AND l.M_Warehouse_ID=?";
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_sqlMinLife = "";
@ -230,7 +229,7 @@ public class PAttributeInstance extends CDialog
} // BPartner != 0
m_sql = m_table.prepareTable (s_layout, s_sqlFrom,
s_sqlWhere, false, "s")
m_M_Warehouse_ID == 0 ? s_sqlWhereWithoutWarehouse : s_sqlWhere, false, "s")
+ " ORDER BY asi.GuaranteeDate, s.QtyOnHand"; // oldest, smallest first
//
m_table.setRowSelectionAllowed(true);
@ -262,8 +261,9 @@ public class PAttributeInstance extends CDialog
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Warehouse_ID);
pstmt.setInt(2, m_M_Product_ID);
pstmt.setInt(1, m_M_Product_ID);
if (m_M_Warehouse_ID != 0)
pstmt.setInt(2, m_M_Warehouse_ID);
ResultSet rs = pstmt.executeQuery();
m_table.loadTable(rs);
rs.close();

View File

@ -501,7 +501,17 @@ public class VPAttributeDialog extends CDialog
private boolean cmd_select()
{
log.config("");
int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_Warehouse_ID");
int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "C_DocType_ID");
if (C_DocType_ID > 0) {
MDocType doctype = new MDocType (Env.getCtx(), C_DocType_ID, null);
String docbase = doctype.getDocBaseType();
if (docbase.equals(MDocType.DOCBASETYPE_MaterialReceipt))
M_Warehouse_ID = 0;
}
// teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes
int M_Locator_ID = 0;
if (m_AD_Column_ID == 8551) { // TODO: hardcoded: M_MovementLine[324].M_AttributeSetInstance_ID[8551]