[ 2608617 ] Error when I want to delete a PO document
https://sourceforge.net/tracker/index.php?func=detail&aid=2608617&group_id=176962&atid=879332 * better exception handling * use new Query API - extensively tested by us
This commit is contained in:
parent
133edfb2db
commit
26cc12bf8a
|
|
@ -18,12 +18,10 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.compiere.process.DocAction;
|
import org.compiere.process.DocAction;
|
||||||
import org.compiere.process.DocumentEngine;
|
import org.compiere.process.DocumentEngine;
|
||||||
|
|
@ -40,9 +38,16 @@ import org.compiere.util.Msg;
|
||||||
* <li> FR [ 2520591 ] Support multiples calendar for Org
|
* <li> FR [ 2520591 ] Support multiples calendar for Org
|
||||||
* @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
|
* @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
|
||||||
* @version $Id: MRequisition.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
|
* @version $Id: MRequisition.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
|
||||||
|
* @author red1
|
||||||
|
* <li>FR [ 2214883 ] Remove SQL code and Replace for Query
|
||||||
*/
|
*/
|
||||||
public class MRequisition extends X_M_Requisition implements DocAction
|
public class MRequisition extends X_M_Requisition implements DocAction
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -4111474920471624816L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* Standard Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
|
@ -93,34 +98,14 @@ public class MRequisition extends X_M_Requisition implements DocAction
|
||||||
return m_lines;
|
return m_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<MRequisitionLine> list = new ArrayList<MRequisitionLine>();
|
//red1 - FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||||
String sql = "SELECT * FROM M_RequisitionLine WHERE M_Requisition_ID=? ORDER BY Line";
|
String whereClause = MRequisitionLine.COLUMNNAME_M_Requisition_ID+"=?";
|
||||||
PreparedStatement pstmt = null;
|
List <MRequisitionLine> list = new Query(getCtx(), MRequisitionLine.Table_Name, whereClause, get_TrxName())
|
||||||
try
|
.setParameters(new Object[]{get_ID()})
|
||||||
{
|
.setOrderBy(MRequisitionLine.COLUMNNAME_Line)
|
||||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
.list();
|
||||||
pstmt.setInt (1, getM_Requisition_ID());
|
// red1 - end -
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
|
||||||
while (rs.next ())
|
|
||||||
list.add (new MRequisitionLine (getCtx(), rs, get_TrxName()));
|
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "getLines", e);
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (pstmt != null)
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
m_lines = new MRequisitionLine[list.size ()];
|
m_lines = new MRequisitionLine[list.size ()];
|
||||||
list.toArray (m_lines);
|
list.toArray (m_lines);
|
||||||
return m_lines;
|
return m_lines;
|
||||||
|
|
@ -286,14 +271,14 @@ public class MRequisition extends X_M_Requisition implements DocAction
|
||||||
if (lineNet.compareTo(line.getLineNetAmt()) != 0)
|
if (lineNet.compareTo(line.getLineNetAmt()) != 0)
|
||||||
{
|
{
|
||||||
line.setLineNetAmt(lineNet);
|
line.setLineNetAmt(lineNet);
|
||||||
line.save();
|
line.saveEx();
|
||||||
}
|
}
|
||||||
totalLines = totalLines.add (line.getLineNetAmt());
|
totalLines = totalLines.add (line.getLineNetAmt());
|
||||||
}
|
}
|
||||||
if (totalLines.compareTo(getTotalLines()) != 0)
|
if (totalLines.compareTo(getTotalLines()) != 0)
|
||||||
{
|
{
|
||||||
setTotalLines(totalLines);
|
setTotalLines(totalLines);
|
||||||
save();
|
saveEx();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
|
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
|
||||||
|
|
@ -442,14 +427,14 @@ public class MRequisition extends X_M_Requisition implements DocAction
|
||||||
line.setDescription(description);
|
line.setDescription(description);
|
||||||
line.setQty(finalQty);
|
line.setQty(finalQty);
|
||||||
line.setLineNetAmt();
|
line.setLineNetAmt();
|
||||||
line.save();
|
line.saveEx();
|
||||||
}
|
}
|
||||||
totalLines = totalLines.add (line.getLineNetAmt());
|
totalLines = totalLines.add (line.getLineNetAmt());
|
||||||
}
|
}
|
||||||
if (totalLines.compareTo(getTotalLines()) != 0)
|
if (totalLines.compareTo(getTotalLines()) != 0)
|
||||||
{
|
{
|
||||||
setTotalLines(totalLines);
|
setTotalLines(totalLines);
|
||||||
save();
|
saveEx();
|
||||||
}
|
}
|
||||||
// After Close
|
// After Close
|
||||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE);
|
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE);
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,14 @@ import org.compiere.util.Env;
|
||||||
*
|
*
|
||||||
* @author Teo Sarca, www.arhipac.ro
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
* <li>BF [ 2419978 ] Voiding PO, requisition don't set on NULL
|
* <li>BF [ 2419978 ] Voiding PO, requisition don't set on NULL
|
||||||
|
* <li>BF [ 2608617 ] Error when I want to delete a PO document
|
||||||
*/
|
*/
|
||||||
public class MRequisitionLine extends X_M_RequisitionLine
|
public class MRequisitionLine extends X_M_RequisitionLine
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 6288086509043522278L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get corresponding Requisition Line for given Order Line
|
* Get corresponding Requisition Line for given Order Line
|
||||||
|
|
@ -73,18 +77,19 @@ public class MRequisitionLine extends X_M_RequisitionLine
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get corresponding Requisition Line for given Order Line
|
* Get corresponding Requisition Line(s) for given Order Line
|
||||||
* @param ctx
|
* @param ctx
|
||||||
* @param C_OrderLine_ID order line
|
* @param C_OrderLine_ID order line
|
||||||
* @param trxName
|
* @param trxName
|
||||||
* @return Requisition Line
|
* @return array of Requisition Line(s)
|
||||||
*/
|
*/
|
||||||
public static MRequisitionLine forC_OrderLine_ID(Properties ctx, int C_OrderLine_ID, String trxName)
|
public static MRequisitionLine[] forC_OrderLine_ID(Properties ctx, int C_OrderLine_ID, String trxName)
|
||||||
{
|
{
|
||||||
final String whereClause = COLUMNNAME_C_OrderLine_ID+"=?";
|
final String whereClause = COLUMNNAME_C_OrderLine_ID+"=?";
|
||||||
return new Query(ctx, MRequisitionLine.Table_Name, whereClause, trxName)
|
List<MRequisitionLine> list = new Query(ctx, MRequisitionLine.Table_Name, whereClause, trxName)
|
||||||
.setParameters(new Object[]{C_OrderLine_ID})
|
.setParameters(new Object[]{C_OrderLine_ID})
|
||||||
.firstOnly();
|
.list();
|
||||||
|
return list.toArray(new MRequisitionLine[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -95,8 +100,7 @@ public class MRequisitionLine extends X_M_RequisitionLine
|
||||||
*/
|
*/
|
||||||
public static void unlinkC_OrderLine_ID(Properties ctx, int C_OrderLine_ID, String trxName)
|
public static void unlinkC_OrderLine_ID(Properties ctx, int C_OrderLine_ID, String trxName)
|
||||||
{
|
{
|
||||||
MRequisitionLine line = forC_OrderLine_ID(ctx, C_OrderLine_ID, trxName);
|
for (MRequisitionLine line : forC_OrderLine_ID(ctx, C_OrderLine_ID, trxName))
|
||||||
if (line != null)
|
|
||||||
{
|
{
|
||||||
line.setC_OrderLine_ID(0);
|
line.setC_OrderLine_ID(0);
|
||||||
line.saveEx();
|
line.saveEx();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue