Search in sources :

Example 1 with CompanyRepository

use of com.axelor.apps.base.db.repo.CompanyRepository in project axelor-open-suite by axelor.

the class ConvertLeadWizardController method setConvertLeadIntoOpportunity.

public void setConvertLeadIntoOpportunity(ActionRequest request, ActionResponse response) throws AxelorException {
    Lead lead = findLead(request);
    AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
    response.setAttr("lead", "value", lead);
    response.setAttr("amount", "value", lead.getEstimatedBudget());
    response.setAttr("customerDescription", "value", lead.getDescription());
    response.setAttr("source", "value", lead.getSource());
    response.setAttr("partner", "value", lead.getPartner());
    response.setAttr("user", "value", lead.getUser());
    response.setAttr("team", "value", lead.getTeam());
    response.setAttr("webSite", "value", lead.getWebSite());
    response.setAttr("source", "value", lead.getSource());
    response.setAttr("department", "value", lead.getDepartment());
    response.setAttr("isCustomer", "value", true);
    response.setAttr("partnerTypeSelect", "value", "1");
    response.setAttr("language", "value", appBase.getDefaultPartnerLanguage());
    Company company = null;
    CompanyRepository companyRepo = Beans.get(CompanyRepository.class);
    if (lead.getUser() != null && lead.getUser().getActiveCompany() != null) {
        company = lead.getUser().getActiveCompany();
    } else if (companyRepo.all().count() == 1) {
        company = companyRepo.all().fetchOne();
    }
    if (company != null) {
        response.setAttr("company", "value", company);
        response.setAttr("currency", "value", company.getCurrency());
    }
}
Also used : Company(com.axelor.apps.base.db.Company) CompanyRepository(com.axelor.apps.base.db.repo.CompanyRepository) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) Lead(com.axelor.apps.crm.db.Lead) AppBase(com.axelor.apps.base.db.AppBase)

Aggregations

AppBase (com.axelor.apps.base.db.AppBase)1 Company (com.axelor.apps.base.db.Company)1 CompanyRepository (com.axelor.apps.base.db.repo.CompanyRepository)1 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 Lead (com.axelor.apps.crm.db.Lead)1