IDEMPIERE-2318 Null pointer exception when Product has not Attribute set configured and costing level is batch

This commit is contained in:
Carlos Ruiz 2018-04-28 16:37:11 +02:00
parent 9cbbc54ba3
commit 2021d451c2
6 changed files with 5 additions and 65 deletions

View File

@ -1190,12 +1190,7 @@ public class MInOut extends X_M_InOut implements DocAction
continue;
if (product != null && product.isASIMandatory(isSOTrx()))
{
if(product.getAttributeSet()==null){
m_processMsg = "@NoAttributeSet@=" + product.getValue();
return DocAction.STATUS_Invalid;
}
if (! product.getAttributeSet().excludeTableEntry(MInOutLine.Table_ID, isSOTrx())) {
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MInOutLine.Table_ID, isSOTrx())) {
m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() +
", @M_Product_ID@=" + product.getValue() + ")";
return DocAction.STATUS_Invalid;

View File

@ -343,7 +343,7 @@ public class MInventory extends X_M_Inventory implements DocAction
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID());
if (product != null && product.isASIMandatory(line.isSOTrx()))
{
if (! product.getAttributeSet().excludeTableEntry(MInventoryLine.Table_ID, line.isSOTrx())) {
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MInventoryLine.Table_ID, line.isSOTrx())) {
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
String docSubTypeInv = dt.getDocSubTypeInv();
BigDecimal qtyDiff = line.getQtyInternalUse();

View File

@ -261,27 +261,6 @@ public class MInventoryLine extends X_M_InventoryLine
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InventoryLine"));
return false;
}
/* IDEMPIERE-1770 - ASI validation must be moved to MInventory.prepareIt, saving a line without ASI is ok on draft
if (m_isManualEntry)
{
// Product requires ASI
if (getM_AttributeSetInstance_ID() == 0)
{
MProduct product = MProduct.get(getCtx(), getM_Product_ID());
if (product != null && product.isASIMandatory(isSOTrx()))
{
if(product.getAttributeSet()==null){
log.saveError("NoAttributeSet", product.getValue());
return false;
}
if (! product.getAttributeSet().excludeTableEntry(MInventoryLine.Table_ID, isSOTrx())) {
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID));
return false;
}
}
} // No ASI
} // manual
*/
// Set Line No
if (getLine() == 0)

View File

@ -298,7 +298,7 @@ public class MMovement extends X_M_Movement implements DocAction
MProduct product = line.getProduct();
if (line.getM_AttributeSetInstance_ID() == 0) {
if (product != null && product.isASIMandatory(true)) {
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true)) { // outgoing
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true)) { // outgoing
BigDecimal qtyDiff = line.getMovementQty();
// verify if the ASIs are captured on lineMA
MMovementLineMA mas[] = MMovementLineMA.get(getCtx(),
@ -320,7 +320,7 @@ public class MMovement extends X_M_Movement implements DocAction
{
if (product != null && product.isASIMandatory(false) && line.getM_AttributeSetInstanceTo_ID() == 0)
{
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false)) { // incoming
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false)) { // incoming
m_processMsg = "@Line@ " + line.getLine() + ": @FillMandatory@ @M_AttributeSetInstanceTo_ID@";
return DocAction.STATUS_Invalid;
}

View File

@ -208,22 +208,6 @@ public class MMovementLine extends X_M_MovementLine
if (newRecord || is_ValueChanged(COLUMNNAME_MovementQty))
setMovementQty(getMovementQty());
// Mandatory Instance
/* IDEMPIERE-1770 - ASI validation must be moved to MMovement.prepareIt, saving a line without ASI is ok on draft
MProduct product = getProduct();
if (getM_AttributeSetInstance_ID() == 0) {
if (product != null && product.isASIMandatory(true)) {
if (product.getAttributeSet()==null) {
log.saveError("NoAttributeSet", product.getValue());
return false;
}
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true)) { // outgoing
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID));
return false;
}
}
}
*/
if (getM_AttributeSetInstanceTo_ID() == 0)
{
//instance id default to same for movement between locator
@ -233,19 +217,6 @@ public class MMovementLine extends X_M_MovementLine
setM_AttributeSetInstanceTo_ID(getM_AttributeSetInstance_ID());
}
/* IDEMPIERE-1770 - ASI validation must be moved to MMovement.prepareIt, saving a line without ASI is ok on draft
if (product != null && product.isASIMandatory(false) && getM_AttributeSetInstanceTo_ID() == 0)
{
if (product.getAttributeSet()==null) {
log.saveError("NoAttributeSet", product.getValue());
return false;
}
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false)) { // incoming
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstanceTo_ID));
return false;
}
}
*/
} // ASI
return true;

View File

@ -1347,12 +1347,7 @@ public class MOrder extends X_C_Order implements DocAction
if (line.getM_Product_ID() > 0 && line.getM_AttributeSetInstance_ID() == 0) {
MProduct product = line.getProduct();
if (product.isASIMandatory(isSOTrx())) {
if(product.getAttributeSet()==null){
m_processMsg = "@NoAttributeSet@=" + product.getValue();
return DocAction.STATUS_Invalid;
}
if (! product.getAttributeSet().excludeTableEntry(MOrderLine.Table_ID, isSOTrx())) {
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MOrderLine.Table_ID, isSOTrx())) {
StringBuilder msg = new StringBuilder("@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #")
.append(line.getLine())
.append(", @M_Product_ID@=")