use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class OpportunitySaleOrderController method cancelSaleOrders.
public void cancelSaleOrders(ActionRequest request, ActionResponse response) {
Opportunity opportunity = request.getContext().asType(Opportunity.class);
SaleOrderWorkflowService saleOrderWorkflowService = Beans.get(SaleOrderWorkflowService.class);
if (opportunity.getSalesStageSelect() == OpportunityRepository.SALES_STAGE_CLOSED_LOST) {
List<SaleOrder> saleOrderList = opportunity.getSaleOrderList();
if (saleOrderList != null && !saleOrderList.isEmpty()) {
for (SaleOrder saleOrder : saleOrderList) {
if (saleOrder.getStatusSelect() == SaleOrderRepository.STATUS_DRAFT_QUOTATION || saleOrder.getStatusSelect() == SaleOrderRepository.STATUS_FINALIZED_QUOTATION) {
saleOrderWorkflowService.cancelSaleOrder(saleOrder, null, opportunity.getName());
}
}
}
}
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method compute.
public void compute(ActionRequest request, ActionResponse response) {
SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
try {
saleOrder = Beans.get(SaleOrderComputeService.class).computeSaleOrder(saleOrder);
response.setValues(saleOrder);
} 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 updateSaleOrderLineTax.
public void updateSaleOrderLineTax(ActionRequest request, ActionResponse response) throws AxelorException {
SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
Beans.get(SaleOrderCreateService.class).updateSaleOrderLineList(saleOrder);
response.setValue("saleOrderLineList", saleOrder.getSaleOrderLineList());
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method fillPriceList.
/**
* Called from sale order form view on partner change. Get the default price list for the sale
* order. Call {@link PartnerPriceListService#getDefaultPriceList(Partner, int)}.
*
* @param request
* @param response
*/
@SuppressWarnings("unchecked")
public void fillPriceList(ActionRequest request, ActionResponse response) {
SaleOrder saleOrder;
if (request.getContext().get("_saleOrderTemplate") != null) {
LinkedHashMap<String, Object> saleOrderTemplateContext = (LinkedHashMap<String, Object>) request.getContext().get("_saleOrderTemplate");
Integer saleOrderId = (Integer) saleOrderTemplateContext.get("id");
saleOrder = Beans.get(SaleOrderRepository.class).find(Long.valueOf(saleOrderId));
} else {
saleOrder = request.getContext().asType(SaleOrder.class);
}
response.setValue("priceList", saleOrder.getClientPartner() != null ? Beans.get(PartnerPriceListService.class).getDefaultPriceList(saleOrder.getClientPartner(), PriceListRepository.TYPE_SALE) : null);
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method createTemplate.
public void createTemplate(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
if (context.get("_idCopy") != null) {
String idCopy = context.get("_idCopy").toString();
SaleOrder origin = Beans.get(SaleOrderRepository.class).find(Long.parseLong(idCopy));
SaleOrder copy = Beans.get(SaleOrderCreateService.class).createTemplate(origin);
response.setValues(Mapper.toMap(copy));
}
}
Aggregations