Search in sources :

Example 6 with Opportunity

use of com.axelor.apps.crm.db.Opportunity in project axelor-open-suite by axelor.

the class OpportunityController method createClient.

public void createClient(ActionRequest request, ActionResponse response) {
    try {
        Opportunity opportunity = request.getContext().asType(Opportunity.class);
        opportunity = Beans.get(OpportunityRepository.class).find(opportunity.getId());
        Beans.get(OpportunityService.class).createClientFromLead(opportunity);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(e);
        response.setError(e.getMessage());
    }
}
Also used : Opportunity(com.axelor.apps.crm.db.Opportunity) OpportunityService(com.axelor.apps.crm.service.OpportunityService)

Example 7 with Opportunity

use of com.axelor.apps.crm.db.Opportunity in project axelor-open-suite by axelor.

the class OpportunitySaleOrderController method generateSaleOrder.

public void generateSaleOrder(ActionRequest request, ActionResponse response) throws AxelorException {
    Opportunity opportunity = request.getContext().asType(Opportunity.class);
    opportunity = Beans.get(OpportunityRepository.class).find(opportunity.getId());
    SaleOrder saleOrder = Beans.get(OpportunitySaleOrderService.class).createSaleOrderFromOpportunity(opportunity);
    response.setReload(true);
    response.setView(ActionView.define(I18n.get(ITranslation.SALE_QUOTATION)).model(SaleOrder.class.getName()).add("form", "sale-order-form").param("forceEdit", "true").param("forceTitle", "true").context("_showRecord", String.valueOf(saleOrder.getId())).map());
}
Also used : Opportunity(com.axelor.apps.crm.db.Opportunity) OpportunitySaleOrderService(com.axelor.apps.sale.service.saleorder.OpportunitySaleOrderService) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 8 with Opportunity

use of com.axelor.apps.crm.db.Opportunity in project axelor-open-suite by axelor.

the class SaleOrderWorkflowServiceImpl method confirmSaleOrder.

@Override
@Transactional(rollbackOn = { Exception.class })
public void confirmSaleOrder(SaleOrder saleOrder) throws AxelorException {
    saleOrder.setStatusSelect(SaleOrderRepository.STATUS_ORDER_CONFIRMED);
    saleOrder.setConfirmationDateTime(appSaleService.getTodayDateTime().toLocalDateTime());
    saleOrder.setConfirmedByUser(userService.getUser());
    this.validateCustomer(saleOrder);
    if (appSaleService.getAppSale().getCloseOpportunityUponSaleOrderConfirmation()) {
        Opportunity opportunity = saleOrder.getOpportunity();
        if (opportunity != null) {
            opportunity.setSalesStageSelect(OpportunityRepository.SALES_STAGE_CLOSED_WON);
        }
    }
    saleOrderRepo.save(saleOrder);
}
Also used : Opportunity(com.axelor.apps.crm.db.Opportunity) Transactional(com.google.inject.persist.Transactional)

Example 9 with Opportunity

use of com.axelor.apps.crm.db.Opportunity in project axelor-open-suite by axelor.

the class OpportunityManagementRepository method copy.

@Override
public Opportunity copy(Opportunity entity, boolean deep) {
    Opportunity copy = super.copy(entity, deep);
    copy.setSalesStageSelect(OpportunityRepository.SALES_STAGE_NEW);
    copy.setLostReason(null);
    copy.setOpportunitySeq(null);
    return copy;
}
Also used : Opportunity(com.axelor.apps.crm.db.Opportunity)

Aggregations

Opportunity (com.axelor.apps.crm.db.Opportunity)9 OpportunityService (com.axelor.apps.crm.service.OpportunityService)2 SaleOrder (com.axelor.apps.sale.db.SaleOrder)2 Transactional (com.google.inject.persist.Transactional)2 Address (com.axelor.apps.base.db.Address)1 Partner (com.axelor.apps.base.db.Partner)1 PartnerService (com.axelor.apps.base.service.PartnerService)1 Event (com.axelor.apps.crm.db.Event)1 OpportunityRepository (com.axelor.apps.crm.db.repo.OpportunityRepository)1 OpportunitySaleOrderService (com.axelor.apps.sale.service.saleorder.OpportunitySaleOrderService)1 SaleOrderWorkflowService (com.axelor.apps.sale.service.saleorder.SaleOrderWorkflowService)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1