Search in sources :

Example 1 with ProjectTaskRepository

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

the class ProjectTaskController method updateToInvoice.

/**
 * Invert value of 'toInvoice' field and save the record
 *
 * @param request
 * @param response
 */
@Transactional
public void updateToInvoice(ActionRequest request, ActionResponse response) {
    ProjectTaskRepository projectTaskRepository = Beans.get(ProjectTaskRepository.class);
    try {
        ProjectTask projectTask = request.getContext().asType(ProjectTask.class);
        projectTask = projectTaskRepository.find(projectTask.getId());
        projectTask.setToInvoice(!projectTask.getToInvoice());
        projectTaskRepository.save(projectTask);
        response.setValue("toInvoice", projectTask.getToInvoice());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ProjectTaskRepository(com.axelor.apps.project.db.repo.ProjectTaskRepository) ProjectTask(com.axelor.apps.project.db.ProjectTask) Transactional(com.google.inject.persist.Transactional)

Aggregations

ProjectTask (com.axelor.apps.project.db.ProjectTask)1 ProjectTaskRepository (com.axelor.apps.project.db.repo.ProjectTaskRepository)1 Transactional (com.google.inject.persist.Transactional)1