Search in sources :

Example 86 with SaleOrder

use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.

the class SaleOrderController method generateViewSaleOrder.

@SuppressWarnings("unchecked")
public void generateViewSaleOrder(ActionRequest request, ActionResponse response) {
    LinkedHashMap<String, Object> saleOrderTemplateContext = (LinkedHashMap<String, Object>) request.getContext().get("_saleOrderTemplate");
    Integer saleOrderId = (Integer) saleOrderTemplateContext.get("id");
    SaleOrder context = Beans.get(SaleOrderRepository.class).find(Long.valueOf(saleOrderId));
    response.setView(ActionView.define("Sale order").model(SaleOrder.class.getName()).add("form", "sale-order-form-wizard").context("_idCopy", context.getId().toString()).context("_wizardCurrency", request.getContext().get("currency")).context("_wizardPriceList", request.getContext().get("priceList")).map());
    response.setCanClose(true);
}
Also used : SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) SaleOrder(com.axelor.apps.sale.db.SaleOrder) LinkedHashMap(java.util.LinkedHashMap)

Example 87 with SaleOrder

use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.

the class SaleOrderController method enableEditOrder.

public void enableEditOrder(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = Beans.get(SaleOrderRepository.class).find(request.getContext().asType(SaleOrder.class).getId());
    try {
        boolean checkAvailabiltyRequest = Beans.get(SaleOrderService.class).enableEditOrder(saleOrder);
        response.setReload(true);
        if (checkAvailabiltyRequest) {
            response.setNotify(I18n.get(IExceptionMessage.SALE_ORDER_EDIT_ORDER_NOTIFY));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : SaleOrderService(com.axelor.apps.sale.service.saleorder.SaleOrderService) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) SaleOrder(com.axelor.apps.sale.db.SaleOrder) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 88 with SaleOrder

use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.

the class SaleOrderController method completeSaleOrder.

public void completeSaleOrder(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrder.getId());
    try {
        Beans.get(SaleOrderWorkflowServiceImpl.class).completeSaleOrder(saleOrder);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
    response.setReload(true);
}
Also used : SaleOrderWorkflowServiceImpl(com.axelor.apps.sale.service.saleorder.SaleOrderWorkflowServiceImpl) SaleOrder(com.axelor.apps.sale.db.SaleOrder) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 89 with SaleOrder

use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.

the class SaleOrderController method getSaleOrderPartnerDomain.

public void getSaleOrderPartnerDomain(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    Company company = saleOrder.getCompany();
    Long companyPartnerId = company.getPartner() == null ? 0 : company.getPartner().getId();
    String domain = String.format("self.id != %d AND self.isContact = false AND (self.isCustomer = true or self.isProspect = true)", companyPartnerId);
    domain += " AND :company member of self.companySet";
    try {
        if (!(saleOrder.getSaleOrderLineList() == null || saleOrder.getSaleOrderLineList().isEmpty())) {
            domain += Beans.get(PartnerService.class).getPartnerDomain(saleOrder.getClientPartner());
        }
    } catch (Exception e) {
        TraceBackService.trace(e);
        response.setError(e.getMessage());
    }
    response.setAttr("clientPartner", "domain", domain);
}
Also used : Company(com.axelor.apps.base.db.Company) SaleOrder(com.axelor.apps.sale.db.SaleOrder) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 90 with SaleOrder

use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.

the class SaleOrderController method finalizeQuotation.

public void finalizeQuotation(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrder.getId());
    try {
        Beans.get(SaleOrderWorkflowService.class).finalizeQuotation(saleOrder);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
    response.setReload(true);
}
Also used : SaleOrderWorkflowService(com.axelor.apps.sale.service.saleorder.SaleOrderWorkflowService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Aggregations

SaleOrder (com.axelor.apps.sale.db.SaleOrder)129 AxelorException (com.axelor.exception.AxelorException)53 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)35 BigDecimal (java.math.BigDecimal)24 Context (com.axelor.rpc.Context)20 Transactional (com.google.inject.persist.Transactional)19 ArrayList (java.util.ArrayList)19 SaleOrderRepository (com.axelor.apps.sale.db.repo.SaleOrderRepository)18 Company (com.axelor.apps.base.db.Company)16 Partner (com.axelor.apps.base.db.Partner)15 IOException (java.io.IOException)13 BirtException (org.eclipse.birt.core.exception.BirtException)13 Invoice (com.axelor.apps.account.db.Invoice)12 List (java.util.List)12 Currency (com.axelor.apps.base.db.Currency)11 SaleOrderLineService (com.axelor.apps.sale.service.saleorder.SaleOrderLineService)10 LinkedHashMap (java.util.LinkedHashMap)10 Map (java.util.Map)9 Product (com.axelor.apps.base.db.Product)8 StockMove (com.axelor.apps.stock.db.StockMove)8