Search in sources :

Example 1 with Configurator

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);
    }
}
Also used : JsonContext(com.axelor.rpc.JsonContext) Configurator(com.axelor.apps.sale.db.Configurator) ConfiguratorService(com.axelor.apps.sale.service.configurator.ConfiguratorService)

Example 2 with Configurator

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());
    }
}
Also used : JsonContext(com.axelor.rpc.JsonContext) Configurator(com.axelor.apps.sale.db.Configurator) Product(com.axelor.apps.base.db.Product) ConfiguratorService(com.axelor.apps.sale.service.configurator.ConfiguratorService)

Example 3 with Configurator

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);
    }
}
Also used : JsonContext(com.axelor.rpc.JsonContext) Configurator(com.axelor.apps.sale.db.Configurator) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) ConfiguratorService(com.axelor.apps.sale.service.configurator.ConfiguratorService) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Aggregations

Configurator (com.axelor.apps.sale.db.Configurator)3 ConfiguratorService (com.axelor.apps.sale.service.configurator.ConfiguratorService)3 JsonContext (com.axelor.rpc.JsonContext)3 Product (com.axelor.apps.base.db.Product)1 SaleOrder (com.axelor.apps.sale.db.SaleOrder)1 SaleOrderRepository (com.axelor.apps.sale.db.repo.SaleOrderRepository)1