Search in sources :

Example 1 with OpportunityRepository

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);
}
Also used : OpportunityRepository(com.axelor.apps.crm.db.repo.OpportunityRepository) Opportunity(com.axelor.apps.crm.db.Opportunity) OpportunityService(com.axelor.apps.crm.service.OpportunityService)

Aggregations

Opportunity (com.axelor.apps.crm.db.Opportunity)1 OpportunityRepository (com.axelor.apps.crm.db.repo.OpportunityRepository)1 OpportunityService (com.axelor.apps.crm.service.OpportunityService)1