Search in sources :

Example 56 with Context

use of com.axelor.rpc.Context in project axelor-open-suite by axelor.

the class PurchaseOrderLineController method getProductInformation.

public void getProductInformation(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
        Context context = request.getContext();
        PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
        PurchaseOrder purchaseOrder = this.getPurchaseOrder(context);
        Product product = purchaseOrderLine.getProduct();
        this.resetProductInformation(response);
        response.setValues(service.reset(purchaseOrderLine));
        if (purchaseOrder == null || product == null) {
            return;
        }
        purchaseOrderLine.setPurchaseOrder(purchaseOrder);
        service.fill(purchaseOrderLine, purchaseOrder);
        response.setValues(purchaseOrderLine);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) Product(com.axelor.apps.base.db.Product) PurchaseOrderLineService(com.axelor.apps.purchase.service.PurchaseOrderLineService)

Example 57 with Context

use of com.axelor.rpc.Context in project axelor-open-suite by axelor.

the class PurchaseOrderLineController method checkQty.

public void checkQty(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
        PurchaseOrder purchaseOrder = getPurchaseOrder(context);
        PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
        service.checkMinQty(purchaseOrder, purchaseOrderLine, request, response);
        service.checkMultipleQty(purchaseOrderLine, response);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) PurchaseOrderLineService(com.axelor.apps.purchase.service.PurchaseOrderLineService)

Example 58 with Context

use of com.axelor.rpc.Context in project axelor-open-suite by axelor.

the class PurchaseOrderLineController method checkDifferentSupplier.

public void checkDifferentSupplier(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
        PurchaseOrder purchaseOrder = getPurchaseOrder(context);
        PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
        service.checkDifferentSupplier(purchaseOrder, purchaseOrderLine, response);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) PurchaseOrderLineService(com.axelor.apps.purchase.service.PurchaseOrderLineService)

Example 59 with Context

use of com.axelor.rpc.Context in project axelor-open-suite by axelor.

the class QualityControlController method sendEmail.

@SuppressWarnings("unchecked")
public void sendEmail(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        QualityControlService qualityControlService = Beans.get(QualityControlService.class);
        if (!ObjectUtils.isEmpty(context.get("_ids"))) {
            List<Long> idList = Lists.transform((List) context.get("_ids"), new Function<Object, Long>() {

                @Nullable
                @Override
                public Long apply(@Nullable Object input) {
                    return Long.parseLong(input.toString());
                }
            });
            QualityControlRepository qualityControlRepo = Beans.get(QualityControlRepository.class);
            for (Long id : idList) {
                QualityControl qualityControl = qualityControlRepo.find(id);
                if (qualityControl.getStatusSelect() == QualityControlRepository.STATUS_FINISHED) {
                    qualityControlService.sendEmail(qualityControl);
                }
            }
        } else if (!ObjectUtils.isEmpty(context.get("id"))) {
            QualityControl qualityControl = context.asType(QualityControl.class);
            qualityControlService.sendEmail(qualityControl);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) QualityControl(com.axelor.apps.quality.db.QualityControl) QualityControlService(com.axelor.apps.quality.service.QualityControlService) QualityControlRepository(com.axelor.apps.quality.db.repo.QualityControlRepository) Nullable(javax.annotation.Nullable) AxelorException(com.axelor.exception.AxelorException)

Example 60 with Context

use of com.axelor.rpc.Context in project axelor-open-suite by axelor.

the class SaleOrderLineController method supplierPartnerDefault.

/**
 * Called from sale order line form, on product change and on sale supply select change
 *
 * @param request
 * @param response
 */
public void supplierPartnerDefault(ActionRequest request, ActionResponse response) {
    SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
    if (saleOrderLine.getSaleSupplySelect() != SaleOrderLineRepository.SALE_SUPPLY_PURCHASE) {
        return;
    }
    SaleOrder saleOrder = saleOrderLine.getSaleOrder();
    if (saleOrder == null) {
        Context parentContext = request.getContext().getParent();
        if (parentContext == null) {
            return;
        }
        saleOrder = parentContext.asType(SaleOrder.class);
    }
    if (saleOrder == null) {
        return;
    }
    Partner supplierPartner = null;
    if (saleOrderLine.getProduct() != null) {
        supplierPartner = saleOrderLine.getProduct().getDefaultSupplierPartner();
    }
    if (supplierPartner != null) {
        Blocking blocking = Beans.get(BlockingService.class).getBlocking(supplierPartner, saleOrder.getCompany(), BlockingRepository.PURCHASE_BLOCKING);
        if (blocking != null) {
            supplierPartner = null;
        }
    }
    response.setValue("supplierPartner", supplierPartner);
}
Also used : Context(com.axelor.rpc.Context) Blocking(com.axelor.apps.base.db.Blocking) BlockingService(com.axelor.apps.base.service.BlockingService) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) SaleOrder(com.axelor.apps.sale.db.SaleOrder) Partner(com.axelor.apps.base.db.Partner)

Aggregations

Context (com.axelor.rpc.Context)149 AxelorException (com.axelor.exception.AxelorException)52 BigDecimal (java.math.BigDecimal)37 Map (java.util.Map)37 HashMap (java.util.HashMap)26 ArrayList (java.util.ArrayList)23 SaleOrder (com.axelor.apps.sale.db.SaleOrder)19 List (java.util.List)18 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)17 Invoice (com.axelor.apps.account.db.Invoice)16 LinkedHashMap (java.util.LinkedHashMap)15 Product (com.axelor.apps.base.db.Product)14 Model (com.axelor.db.Model)13 StockMove (com.axelor.apps.stock.db.StockMove)12 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)12 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)11 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)11 LocalDate (java.time.LocalDate)11 Beans (com.axelor.inject.Beans)10 ActionRequest (com.axelor.rpc.ActionRequest)10