use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderController method print.
/**
* Method that generate a Pdf file for an manufacturing order
*
* @param request
* @param response
* @return
* @throws BirtException
* @throws IOException
*/
public void print(ActionRequest request, ActionResponse response) {
try {
ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
ManufOrderPrintService manufOrderPrintService = Beans.get(ManufOrderPrintService.class);
@SuppressWarnings("unchecked") List<Integer> selectedManufOrderList = (List<Integer>) request.getContext().get("_ids");
if (selectedManufOrderList != null) {
String name = manufOrderPrintService.getManufOrdersFilename();
String fileLink = manufOrderPrintService.printManufOrders(selectedManufOrderList.stream().map(Integer::longValue).collect(Collectors.toList()));
LOG.debug("Printing {}", name);
response.setView(ActionView.define(name).add("html", fileLink).map());
} else if (manufOrder != null) {
String name = manufOrderPrintService.getFileName(manufOrder);
String fileLink = manufOrderPrintService.printManufOrder(manufOrder);
LOG.debug("Printing {}", name);
response.setView(ActionView.define(name).add("html", fileLink).map());
} else {
response.setFlash(I18n.get(IExceptionMessage.MANUF_ORDER_1));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderController method resume.
public void resume(ActionRequest request, ActionResponse response) {
try {
Long manufOrderId = (Long) request.getContext().get("id");
ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderId);
Beans.get(ManufOrderWorkflowService.class).resume(manufOrder);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderController method updatePlannedDates.
public void updatePlannedDates(ActionRequest request, ActionResponse response) {
try {
ManufOrder manufOrderView = request.getContext().asType(ManufOrder.class);
if (manufOrderView.getStatusSelect() == ManufOrderRepository.STATUS_PLANNED) {
ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderView.getId());
if (manufOrderView.getPlannedStartDateT() != null) {
if (!manufOrderView.getPlannedStartDateT().isEqual(manufOrder.getPlannedStartDateT())) {
Beans.get(ManufOrderWorkflowService.class).updatePlannedDates(manufOrder, manufOrderView.getPlannedStartDateT());
response.setReload(true);
}
} else {
response.setValue("plannedStartDateT", manufOrder.getPlannedStartDateT());
}
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderController method plan.
public void plan(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
List<ManufOrder> manufOrders = new ArrayList<>();
if (context.get("id") != null) {
Long manufOrderId = (Long) request.getContext().get("id");
manufOrders.add(Beans.get(ManufOrderRepository.class).find(manufOrderId));
} else if (context.get("_ids") != null) {
manufOrders = Beans.get(ManufOrderRepository.class).all().filter("self.id in ?1 and self.statusSelect in (?2,?3)", context.get("_ids"), ManufOrderRepository.STATUS_DRAFT, ManufOrderRepository.STATUS_CANCELED).fetch();
}
for (ManufOrder manufOrder : manufOrders) {
Beans.get(ManufOrderWorkflowService.class).plan(manufOrder);
if (manufOrder.getProdProcess().getGeneratePurchaseOrderOnMoPlanning()) {
Beans.get(ManufOrderWorkflowService.class).createPurchaseOrder(manufOrder);
}
}
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderController method updatePlannedQty.
/**
* Called from manuf order wizard view. Call {@link
* ManufOrderService#updatePlannedQty(ManufOrder)}
*
* @param request
* @param response
*/
public void updatePlannedQty(ActionRequest request, ActionResponse response) {
try {
ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
Beans.get(ManufOrderService.class).updatePlannedQty(manufOrder);
response.setReload(true);
response.setCanClose(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations