Program: 58489
Project: 58489
Buggy source:
@Transactional public void insertLeave(ActionRequest request,ActionResponse response) throws AxelorException {
  AppBaseService appBaseService=Beans.get(AppBaseService.class);
  LeaveLineRepository leaveLineRepo=Beans.get(LeaveLineRepository.class);
  User user=AuthUtils.getUser();
  Map<String,Object> requestData=request.getData();
  LeaveReason leaveReason=Beans.get(LeaveReasonRepository.class).find(new Long(requestData.get("String_Node_Str").toString()));
  if (user.getEmployee() == null) {
    throw new AxelorException(IException.CONFIGURATION_ERROR,I18n.get(IExceptionMessage.LEAVE_USER_EMPLOYEE),user.getName());
  }
  if (user != null && leaveReason != null) {
    LeaveRequest leave=new LeaveRequest();
    leave.setUser(user);
    Company company=null;
    if (user.getEmployee() != null && user.getEmployee().getMainEmploymentContract() != null) {
      company=user.getEmployee().getMainEmploymentContract().getPayCompany();
    }
    leave.setCompany(company);
    LeaveLine leaveLine=leaveLineRepo.all().filter("String_Node_Str",user.getEmployee(),leaveReason).fetchOne();
    if (leaveLine == null) {
      throw new AxelorException(IException.CONFIGURATION_ERROR,I18n.get(IExceptionMessage.LEAVE_LINE),user.getEmployee().getName(),leaveReason.getLeaveReason());
    }
    leave.setLeaveLine(leaveLine);
    leave.setRequestDate(appBaseService.getTodayDate());
    if (requestData.get("String_Node_Str") != null) {
      leave.setFromDate(LocalDate.parse(requestData.get("String_Node_Str").toString(),DateTimeFormatter.ISO_DATE));
    }
    leave.setStartOnSelect(new Integer(requestData.get("String_Node_Str").toString()));
    if (requestData.get("String_Node_Str") != null) {
      leave.setToDate(LocalDate.parse(requestData.get("String_Node_Str").toString(),DateTimeFormatter.ISO_DATE));
    }
    leave.setEndOnSelect(new Integer(requestData.get("String_Node_Str").toString()));
    leave.setDuration(Beans.get(LeaveService.class).computeDuration(leave));
    leave.setStatusSelect(LeaveRequestRepository.STATUS_AWAITING_VALIDATION);
    if (requestData.get("String_Node_Str") != null) {
      leave.setComments(requestData.get("String_Node_Str").toString());
    }
    leave=Beans.get(LeaveRequestRepository.class).save(leave);
    response.setTotal(1);
    HashMap<String,Object> data=new HashMap<String,Object>();
    data.put("String_Node_Str",leave.getId());
    response.setData(data);
  }
}

Fixed version (ground truth):
@Transactional public void insertLeave(ActionRequest request,ActionResponse response) throws AxelorException {
  AppBaseService appBaseService=Beans.get(AppBaseService.class);
  LeaveLineRepository leaveLineRepo=Beans.get(LeaveLineRepository.class);
  User user=AuthUtils.getUser();
  Map<String,Object> requestData=request.getData();
  LeaveReason leaveReason=Beans.get(LeaveReasonRepository.class).find(new Long(requestData.get("String_Node_Str").toString()));
  if (user.getEmployee() == null) {
    throw new AxelorException(IException.CONFIGURATION_ERROR,I18n.get(IExceptionMessage.LEAVE_USER_EMPLOYEE),user.getName());
  }
  if (user != null && leaveReason != null) {
    LeaveRequest leave=new LeaveRequest();
    leave.setUser(user);
    Company company=null;
    if (user.getEmployee() != null && user.getEmployee().getMainEmploymentContract() != null) {
      company=user.getEmployee().getMainEmploymentContract().getPayCompany();
    }
    leave.setCompany(company);
    LeaveLine leaveLine=Beans.get(LeaveLineRepository.class).all().filter("String_Node_Str",user.getEmployee(),leaveReason).fetchOne();
    if (leaveLine == null) {
      throw new AxelorException(IException.CONFIGURATION_ERROR,I18n.get(IExceptionMessage.LEAVE_LINE),user.getEmployee().getName(),leaveReason.getLeaveReason());
    }
    leave.setLeaveLine(leaveLine);
    leave.setRequestDate(appBaseService.getTodayDate());
    if (requestData.get("String_Node_Str") != null) {
      leave.setFromDate(LocalDate.parse(requestData.get("String_Node_Str").toString(),DateTimeFormatter.ISO_DATE));
    }
    leave.setStartOnSelect(new Integer(requestData.get("String_Node_Str").toString()));
    if (requestData.get("String_Node_Str") != null) {
      leave.setToDate(LocalDate.parse(requestData.get("String_Node_Str").toString(),DateTimeFormatter.ISO_DATE));
    }
    leave.setEndOnSelect(new Integer(requestData.get("String_Node_Str").toString()));
    leave.setDuration(Beans.get(LeaveService.class).computeDuration(leave));
    leave.setStatusSelect(LeaveRequestRepository.STATUS_AWAITING_VALIDATION);
    if (requestData.get("String_Node_Str") != null) {
      leave.setComments(requestData.get("String_Node_Str").toString());
    }
    leave=Beans.get(LeaveRequestRepository.class).save(leave);
    response.setTotal(1);
    HashMap<String,Object> data=new HashMap<String,Object>();
    data.put("String_Node_Str",leave.getId());
    response.setData(data);
  }
}