Search in sources :

Example 1 with StockMoveReservedQtyService

use of com.axelor.apps.supplychain.service.StockMoveReservedQtyService in project axelor-open-suite by axelor.

the class StockMoveController method allocateAll.

/**
 * Called from stock move form view, on available qty boolean change. Only called if the user
 * accepted to allocate everything. Call {@link
 * StockMoveReservedQtyService#allocateAll(StockMove)}.
 *
 * @param request
 * @param response
 */
public void allocateAll(ActionRequest request, ActionResponse response) {
    try {
        StockMove stockMove = request.getContext().asType(StockMove.class);
        Company company = stockMove.getCompany();
        if (company == null) {
            return;
        }
        SupplyChainConfig supplyChainConfig = Beans.get(SupplyChainConfigService.class).getSupplyChainConfig(company);
        if (!Beans.get(AppSupplychainService.class).getAppSupplychain().getManageStockReservation() || !stockMove.getAvailabilityRequest() || !supplyChainConfig.getAutoAllocateOnAvailabilityRequest()) {
            return;
        }
        Beans.get(StockMoveReservedQtyService.class).allocateAll(stockMove);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : Company(com.axelor.apps.base.db.Company) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveReservedQtyService(com.axelor.apps.supplychain.service.StockMoveReservedQtyService) SupplyChainConfigService(com.axelor.apps.supplychain.service.config.SupplyChainConfigService) SupplyChainConfig(com.axelor.apps.supplychain.db.SupplyChainConfig) AppSupplychainService(com.axelor.apps.supplychain.service.app.AppSupplychainService)

Aggregations

Company (com.axelor.apps.base.db.Company)1 StockMove (com.axelor.apps.stock.db.StockMove)1 SupplyChainConfig (com.axelor.apps.supplychain.db.SupplyChainConfig)1 StockMoveReservedQtyService (com.axelor.apps.supplychain.service.StockMoveReservedQtyService)1 AppSupplychainService (com.axelor.apps.supplychain.service.app.AppSupplychainService)1 SupplyChainConfigService (com.axelor.apps.supplychain.service.config.SupplyChainConfigService)1