use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method validateChanges.
/**
* Called from sale order form view, on clicking validate change button. Call {@link
* SaleOrderService#validateChanges(SaleOrder)}.
*
* @param request
* @param response
*/
public void validateChanges(ActionRequest request, ActionResponse response) {
try {
SaleOrder saleOrderView = request.getContext().asType(SaleOrder.class);
SaleOrder saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrderView.getId());
Beans.get(SaleOrderService.class).validateChanges(saleOrder);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method exportSaleOrder.
@SuppressWarnings("unchecked")
public void exportSaleOrder(ActionRequest request, ActionResponse response, boolean proforma, String format) {
Context context = request.getContext();
String fileLink;
String title;
SaleOrderPrintService saleOrderPrintService = Beans.get(SaleOrderPrintService.class);
try {
if (!ObjectUtils.isEmpty(request.getContext().get("_ids"))) {
List<Long> ids = Lists.transform((List) request.getContext().get("_ids"), new Function<Object, Long>() {
@Nullable
@Override
public Long apply(@Nullable Object input) {
return Long.parseLong(input.toString());
}
});
fileLink = saleOrderPrintService.printSaleOrders(ids);
title = I18n.get("Sale orders");
} else if (context.get("id") != null) {
SaleOrder saleOrder = Beans.get(SaleOrderRepository.class).find(Long.parseLong(context.get("id").toString()));
title = Beans.get(SaleOrderService.class).getFileName(saleOrder);
fileLink = saleOrderPrintService.printSaleOrder(saleOrder, proforma, format);
response.setCanClose(true);
logger.debug("Printing " + title);
} else {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.SALE_ORDER_PRINT));
}
response.setView(ActionView.define(title).add("html", fileLink).map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method computeEndOfValidityDate.
public void computeEndOfValidityDate(ActionRequest request, ActionResponse response) {
SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
try {
saleOrder = Beans.get(SaleOrderService.class).computeEndOfValidityDate(saleOrder);
response.setValue("endOfValidityDate", saleOrder.getEndOfValidityDate());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method cancelSaleOrder.
public void cancelSaleOrder(ActionRequest request, ActionResponse response) {
SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
Beans.get(SaleOrderWorkflowService.class).cancelSaleOrder(Beans.get(SaleOrderRepository.class).find(saleOrder.getId()), saleOrder.getCancelReason(), saleOrder.getCancelReasonStr());
response.setFlash(I18n.get("The sale order was canceled"));
response.setCanClose(true);
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderLineController method getProductInformation.
/**
* Called by the sale order line form. Update all fields when the product is changed.
*
* @param request
* @param response
*/
public void getProductInformation(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
SaleOrder saleOrder = saleOrderLineService.getSaleOrder(context);
Product product = saleOrderLine.getProduct();
if (saleOrder == null || product == null) {
resetProductInformation(response, saleOrderLine);
return;
}
try {
product = Beans.get(ProductRepository.class).find(product.getId());
saleOrderLineService.computeProductInformation(saleOrderLine, saleOrder);
response.setValue("saleSupplySelect", product.getSaleSupplySelect());
response.setValues(saleOrderLine);
} catch (Exception e) {
resetProductInformation(response, saleOrderLine);
TraceBackService.trace(response, e);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations