use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.
the class TargetListController method openFilteredLeads.
public void openFilteredLeads(ActionRequest request, ActionResponse response) {
TargetList targetList = request.getContext().asType(TargetList.class);
String leadFilters = null;
try {
leadFilters = Beans.get(TargetListService.class).getLeadQuery(targetList);
if (leadFilters != null) {
response.setView(ActionView.define(I18n.get("Leads")).model(Lead.class.getName()).add("grid", "lead-grid").add("form", "lead-form").param("search-filters", "lead-filters").domain(leadFilters).map());
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.
the class LeadController method loseLead.
public void loseLead(ActionRequest request, ActionResponse response) {
try {
Lead lead = request.getContext().asType(Lead.class);
Beans.get(LeadService.class).loseLead(Beans.get(LeadRepository.class).find(lead.getId()), lead.getLostReason());
response.setCanClose(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.
the class LeadServiceImpl method importLead.
@SuppressWarnings("rawtypes")
public Object importLead(Object bean, Map values) {
assert bean instanceof Lead;
Lead lead = (Lead) bean;
User user = AuthUtils.getUser();
lead.setUser(user);
lead.setTeam(user.getActiveTeam());
return lead;
}
use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.
the class OpportunityServiceImpl method createClientFromLead.
@Override
@Transactional(rollbackOn = { Exception.class })
public Partner createClientFromLead(Opportunity opportunity) throws AxelorException {
Lead lead = opportunity.getLead();
if (lead == null) {
throw new AxelorException(opportunity, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.LEAD_PARTNER));
}
String name = lead.getFullName();
Address address = null;
if (lead.getPrimaryAddress() != null) {
// avoids printing 'null'
String addressL6 = lead.getPrimaryPostalCode() == null ? "" : lead.getPrimaryPostalCode() + " ";
addressL6 += lead.getPrimaryCity() == null ? "" : lead.getPrimaryCity().getName();
address = addressService.createAddress(null, null, lead.getPrimaryAddress(), null, addressL6, lead.getPrimaryCountry());
address.setFullName(addressService.computeFullName(address));
}
EmailAddress email = null;
if (lead.getEmailAddress() != null) {
email = new EmailAddress(lead.getEmailAddress().getAddress());
}
Partner partner = Beans.get(PartnerService.class).createPartner(name, null, lead.getFixedPhone(), lead.getMobilePhone(), email, opportunity.getCurrency(), address, address, true);
opportunity.setPartner(partner);
opportunityRepo.save(opportunity);
return partner;
}
use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.
the class ConvertLeadWizardController method setIndividualPartner.
public void setIndividualPartner(ActionRequest request, ActionResponse response) throws AxelorException {
Lead lead = findLead(request);
if (request.getContext().get("partnerTypeSelect").toString().equals("2")) {
response.setAttr("firstName", "value", lead.getFirstName());
response.setAttr("name", "value", lead.getName());
} else {
response.setAttr("name", "value", lead.getEnterpriseName());
}
}
Aggregations