IDEMPIERE-5578 Data corruption when copying order lines from a closed order (#1677)
* IDEMPIERE-5578 Data corruption when copying order lines from a closed order * - refactor MOrderLine.getDescriptionStrippingCloseTag for optimization * - regenerate serialVersionUID
This commit is contained in:
parent
34163826f0
commit
59ded47edf
|
@ -27,7 +27,6 @@ import java.util.Hashtable;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
|
@ -80,7 +79,7 @@ public class MOrder extends X_C_Order implements DocAction
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7784588474522162502L;
|
||||
private static final long serialVersionUID = 1298245367836653594L;
|
||||
|
||||
/**
|
||||
* Create new Order by copying
|
||||
|
@ -548,11 +547,13 @@ public class MOrder extends X_C_Order implements DocAction
|
|||
line.setQtyInvoiced(Env.ZERO);
|
||||
line.setQtyReserved(Env.ZERO);
|
||||
line.setQtyLostSales(Env.ZERO);
|
||||
line.setQty(fromLines[i].getQtyEntered());
|
||||
line.setDateDelivered(null);
|
||||
line.setDateInvoiced(null);
|
||||
//
|
||||
line.setOrder(this);
|
||||
line.set_ValueNoCheck ("C_OrderLine_ID", I_ZERO); // new
|
||||
if (!counter && MOrder.STATUS_Closed.equals(otherOrder.getDocStatus()))
|
||||
line.setDescription(line.getDescriptionStrippingCloseTag());
|
||||
// References
|
||||
if (!copyASI)
|
||||
{
|
||||
|
@ -2681,17 +2682,7 @@ public class MOrder extends X_C_Order implements DocAction
|
|||
line.setQtyLostSales(Env.ZERO);
|
||||
// QtyEntered unchanged
|
||||
|
||||
// Strip Close() tags from description
|
||||
String desc = line.getDescription();
|
||||
if (desc == null)
|
||||
desc = "";
|
||||
Pattern pattern = Pattern.compile("( \\| )?Close \\(.*\\)");
|
||||
String[] parts = pattern.split(desc);
|
||||
desc = "";
|
||||
for (String s : parts) {
|
||||
desc = desc.concat(s);
|
||||
}
|
||||
line.setDescription(desc);
|
||||
line.setDescription(line.getDescriptionStrippingCloseTag());
|
||||
if (!line.save(get_TrxName()))
|
||||
return "Couldn't save orderline";
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.IProductPricing;
|
||||
|
@ -56,7 +57,7 @@ public class MOrderLine extends X_C_OrderLine
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7152360636393521683L;
|
||||
private static final long serialVersionUID = 7994694334621222461L;
|
||||
|
||||
/**
|
||||
* Get Order Unreserved Qty
|
||||
|
@ -1063,4 +1064,21 @@ public class MOrderLine extends X_C_OrderLine
|
|||
{
|
||||
this.m_parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description stripping the Close tag that was created when closing the order
|
||||
* @return
|
||||
*/
|
||||
public String getDescriptionStrippingCloseTag() {
|
||||
String description = getDescription();
|
||||
if (description == null)
|
||||
return description;
|
||||
Pattern pattern = Pattern.compile("( \\| )?Close \\(.*\\)");
|
||||
String[] parts = pattern.split(description);
|
||||
StringBuilder description_sb = new StringBuilder();
|
||||
for (String s : parts)
|
||||
description_sb.append(s);
|
||||
return description_sb.toString();
|
||||
}
|
||||
|
||||
} // MOrderLine
|
||||
|
|
Loading…
Reference in New Issue