IDEMPIERE-4912 Set the product's UOM on beforesave when creating an order line (#827)
This commit is contained in:
parent
8ec5029e8e
commit
ce689bbbc2
|
@ -56,7 +56,7 @@ public class MOrderLine extends X_C_OrderLine
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7152360636393521683L;
|
||||
private static final long serialVersionUID = 7207471169113857831L;
|
||||
|
||||
/**
|
||||
* Get Order Unreserved Qty
|
||||
|
@ -833,15 +833,8 @@ public class MOrderLine extends X_C_OrderLine
|
|||
}
|
||||
|
||||
// UOM
|
||||
if (getC_UOM_ID() == 0
|
||||
&& (getM_Product_ID() != 0
|
||||
|| getPriceEntered().compareTo(Env.ZERO) != 0
|
||||
|| getC_Charge_ID() != 0))
|
||||
{
|
||||
int C_UOM_ID = MUOM.getDefault_UOM_ID(getCtx());
|
||||
if (C_UOM_ID > 0)
|
||||
setC_UOM_ID (C_UOM_ID);
|
||||
}
|
||||
if (getC_UOM_ID() == 0)
|
||||
setDefaultC_UOM_ID();
|
||||
// Qty Precision
|
||||
if (newRecord || is_ValueChanged("QtyEntered"))
|
||||
setQtyEntered(getQtyEntered());
|
||||
|
@ -880,7 +873,24 @@ public class MOrderLine extends X_C_OrderLine
|
|||
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
/***
|
||||
* Sets the default unit of measure
|
||||
* If there's a product, it sets the UOM of the product
|
||||
* If not, it sets the default UOM of the client
|
||||
*/
|
||||
private void setDefaultC_UOM_ID() {
|
||||
int C_UOM_ID = 0;
|
||||
|
||||
if (MProduct.get(getCtx(), getM_Product_ID()) != null) {
|
||||
C_UOM_ID = MProduct.get(getCtx(), getM_Product_ID()).getC_UOM_ID();
|
||||
} else {
|
||||
C_UOM_ID = MUOM.getDefault_UOM_ID(getCtx());
|
||||
}
|
||||
|
||||
if (C_UOM_ID > 0)
|
||||
setC_UOM_ID (C_UOM_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Before Delete
|
||||
|
|
Loading…
Reference in New Issue