Skip to content

Commit

Permalink
518: Picking prototype (v6)
Browse files Browse the repository at this point in the history
* PickingCandidateCommand: 
solve problem that the HU was created, but no qty was picked; thx
@teosarca
* WEBUI_Picking_PickToNewHU: avoid being called with non-picking-slot
item
* WEBUI_Picking_M_Picking_Candidate_Processed: minor

Task-Url: #518
  • Loading branch information
metas-ts committed Jul 25, 2017
1 parent 5d4575b commit f9a93da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.compiere.model.IQuery;
import org.compiere.model.I_C_UOM;
import org.compiere.model.I_M_Product;
import org.compiere.util.Env;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -128,7 +127,7 @@ public Quantity addQtyToHU(
}

final I_M_ShipmentSchedule shipmentSchedule = InterfaceWrapperHelper.load(shipmentScheduleId, I_M_ShipmentSchedule.class);
I_M_Product product = shipmentSchedule.getM_Product();
final I_M_Product product = shipmentSchedule.getM_Product();

final I_M_Picking_Candidate candidate = getCreateCandidate(huId, pickingSlotId, shipmentScheduleId);

Expand Down Expand Up @@ -156,7 +155,9 @@ public Quantity addQtyToHU(
// Request
final IShipmentScheduleBL shipmentScheduleBL = Services.get(IShipmentScheduleBL.class);

final IMutableHUContext huContext = Services.get(IHUContextFactory.class).createMutableHUContextForProcessing(Env.getCtx());
// create the context with the tread-inherited transaction! Otherwise, the loader won't be able to access the HU's material item and therefore won't load anything!
final IMutableHUContext huContext = Services.get(IHUContextFactory.class).createMutableHUContextForProcessing();

final IAllocationRequest request = AllocationUtils.createAllocationRequestBuilder()
.setHUContext(huContext)
.setProduct(product)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import de.metas.fresh.picking.service.IPackingContext;
import de.metas.fresh.picking.service.IPackingService;
import de.metas.fresh.picking.service.impl.HU2PackingItemsAllocator;
import de.metas.handlingunits.IHUPickingSlotBL;
import de.metas.handlingunits.IHandlingUnitsBL;
import de.metas.handlingunits.model.I_M_HU;
import de.metas.handlingunits.model.I_M_Picking_Candidate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ protected ProcessPreconditionsResolution checkPreconditionsApplicable()
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}

final PickingSlotRow pickingSlotRow = getSingleSelectedRow();
if (!pickingSlotRow.isPickingSlotRow())
{
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText("WEBUI_Picking_SelectPickingSlot"));
}

return ProcessPreconditionsResolution.accept();
}

Expand Down Expand Up @@ -164,13 +170,20 @@ private static final I_M_Locator getPickingSlotLocator(final PickingSlotRow pick
final int pickingSlotWarehouseId = pickingSlotRow.getPickingSlotWarehouseId();
if (pickingSlotWarehouseId <= 0)
{
throw new AdempiereException("Picking slot has no warehouse configured");
throw new AdempiereException("Picking slot with M_PickingSlot_ID=" + pickingSlotRow.getPickingSlotId() + " has no warehouse configured");
}
final I_M_Warehouse pickingSlotWarehouse = InterfaceWrapperHelper.loadOutOfTrx(pickingSlotWarehouseId, I_M_Warehouse.class);
final I_M_Locator pickingSlotLocator = Services.get(IWarehouseBL.class).getDefaultLocator(pickingSlotWarehouse);
return pickingSlotLocator;
}

/**
* Creates a new M_HU within the processe's interited trx.
*
* @param itemProduct
* @param locator
* @return
*/
private static final I_M_HU createTU(@NonNull final I_M_HU_PI_Item_Product itemProduct, @NonNull final I_M_Locator locator)
{
final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
Expand Down

0 comments on commit f9a93da

Please sign in to comment.