use of com.axelor.apps.sale.db.Configurator in project axelor-open-suite by axelor.
the class ConfiguratorController method updateIndicators.
/**
* Called from configurator form view, set values for the indicators JSON field. call {@link
* ConfiguratorService#updateIndicators(Configurator, JsonContext, JsonContext)}
*
* @param request
* @param response
*/
public void updateIndicators(ActionRequest request, ActionResponse response) {
Configurator configurator = request.getContext().asType(Configurator.class);
JsonContext jsonAttributes = (JsonContext) request.getContext().get("$attributes");
JsonContext jsonIndicators = (JsonContext) request.getContext().get("$indicators");
configurator = Beans.get(ConfiguratorRepository.class).find(configurator.getId());
try {
Beans.get(ConfiguratorService.class).updateIndicators(configurator, jsonAttributes, jsonIndicators);
response.setValue("indicators", request.getContext().get("indicators"));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.Configurator in project axelor-open-suite by axelor.
the class ConfiguratorController method generateProduct.
/**
* Called from configurator form view, call {@link
* ConfiguratorService#generateProduct(Configurator, JsonContext, JsonContext)}
*
* @param request
* @param response
*/
public void generateProduct(ActionRequest request, ActionResponse response) {
Configurator configurator = request.getContext().asType(Configurator.class);
JsonContext jsonAttributes = (JsonContext) request.getContext().get("$attributes");
JsonContext jsonIndicators = (JsonContext) request.getContext().get("$indicators");
configurator = Beans.get(ConfiguratorRepository.class).find(configurator.getId());
try {
Beans.get(ConfiguratorService.class).generate(configurator, jsonAttributes, jsonIndicators);
response.setReload(true);
if (configurator.getProduct() != null) {
response.setView(ActionView.define(I18n.get("Product generated")).model(Product.class.getName()).add("form", "product-form").add("grid", "product-grid").param("search-filters", "products-filters").context("_showRecord", configurator.getProduct().getId()).map());
}
} catch (Exception e) {
TraceBackService.trace(e);
response.setError(e.getMessage());
}
}
use of com.axelor.apps.sale.db.Configurator in project axelor-open-suite by axelor.
the class ConfiguratorController method generateForSaleOrder.
/**
* Called from configurator wizard form view, call {@link
* ConfiguratorService#addLineToSaleOrder(Configurator, SaleOrder, JsonContext, JsonContext)}
*
* @param request
* @param response
*/
public void generateForSaleOrder(ActionRequest request, ActionResponse response) {
Configurator configurator = request.getContext().asType(Configurator.class);
long saleOrderId = ((Integer) request.getContext().get("_saleOrderId")).longValue();
JsonContext jsonAttributes = (JsonContext) request.getContext().get("$attributes");
JsonContext jsonIndicators = (JsonContext) request.getContext().get("$indicators");
configurator = Beans.get(ConfiguratorRepository.class).find(configurator.getId());
SaleOrder saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrderId);
try {
Beans.get(ConfiguratorService.class).addLineToSaleOrder(configurator, saleOrder, jsonAttributes, jsonIndicators);
response.setCanClose(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations