use of com.axelor.apps.crm.db.repo.OpportunityRepository in project axelor-open-suite by axelor.
the class OpportunityController method assignToMe.
public void assignToMe(ActionRequest request, ActionResponse response) {
OpportunityService opportunityService = Beans.get(OpportunityService.class);
OpportunityRepository opportunityRepository = Beans.get(OpportunityRepository.class);
if (request.getContext().get("id") != null) {
Opportunity opportunity = opportunityRepository.find((Long) request.getContext().get("id"));
opportunity.setUser(AuthUtils.getUser());
opportunityService.saveOpportunity(opportunity);
} else if (ObjectUtils.notEmpty(request.getContext().get("_ids"))) {
for (Opportunity opportunity : opportunityRepository.all().filter("id in ?1", request.getContext().get("_ids")).fetch()) {
opportunity.setUser(AuthUtils.getUser());
opportunityService.saveOpportunity(opportunity);
}
} else {
response.setNotify(com.axelor.apps.base.exceptions.IExceptionMessage.RECORD_NONE_SELECTED);
return;
}
response.setReload(true);
}
Aggregations