IDEMPIERE-5091 - Before Save Set Default Locator From Product Or Warehouse when creating m_inout programatically (#1043)

* IDEMPIERE-5091 - Before Save Set Default Locator From Product Or Warehouse when creating m_inout programatically

* IDEMPIERE-5091 - inefficient methods replaced

Co-authored-by: Igor Pojzl <igor.pojzl@cloudempiere.com>
This commit is contained in:
PeterTakacs300 2022-02-22 23:50:48 +01:00 committed by GitHub
parent 4a7c9c601e
commit 3423e02780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 1 deletions

View File

@ -548,7 +548,26 @@ public class MInOutLine extends X_M_InOutLine
{
if (getM_Locator_ID() <= 0 && getC_Charge_ID() <= 0)
{
throw new FillMandatoryException(COLUMNNAME_M_Locator_ID);
// Try to load Default Locator
MWarehouse warehouse = MWarehouse.get(getM_Warehouse_ID());
if(warehouse != null) {
int m_Locator_ID = getProduct().getM_Locator_ID();
if(m_Locator_ID > 0 && MLocator.get(m_Locator_ID).getM_Warehouse_ID() == warehouse.getM_Warehouse_ID()) {
setM_Locator_ID(m_Locator_ID);
}
else {
MLocator defaultLocator = warehouse.getDefaultLocator();
if(defaultLocator != null)
setM_Locator_ID(defaultLocator.getM_Locator_ID());
}
}
if (getM_Locator_ID() <= 0)
throw new FillMandatoryException(COLUMNNAME_M_Locator_ID);
}
}