Program: 58821
Project: 58821
Buggy source:
protected void checkInsufficientCumulativeQty(Product product) throws AxelorException {
  boolean doASecondPass=false;
  this.computeCumulativeQty(product);
  List<MrpLine> mrpLineList=mrpLineRepository.all().filter("String_Node_Str",mrp,product).order("String_Node_Str").order("String_Node_Str").order("String_Node_Str").order("String_Node_Str").fetch();
  for (  MrpLine mrpLine : mrpLineList) {
    BigDecimal cumulativeQty=mrpLine.getCumulativeQty();
    MrpLineType mrpLineType=mrpLine.getMrpLineType();
    boolean isProposalElement=this.isProposalElement(mrpLineType);
    BigDecimal minQty=mrpLine.getMinQty();
    if (mrpLine.getMrpLineType().getElementSelect() != MrpLineTypeRepository.ELEMENT_AVAILABLE_STOCK && (!isProposalElement || (isProposalElement && mrpLineType.getTypeSelect() == MrpLineTypeRepository.TYPE_OUT)) && cumulativeQty.compareTo(mrpLine.getMinQty()) == -1) {
      log.debug("String_Node_Str",cumulativeQty,minQty,product.getFullName(),mrpLine.getMaturityDate());
      BigDecimal reorderQty=minQty.subtract(cumulativeQty);
      MinStockRules minStockRules=minStockRulesService.getMinStockRules(product,mrpLine.getLocation(),MinStockRulesRepository.TYPE_FUTURE);
      if (minStockRules != null) {
        reorderQty=reorderQty.max(minStockRules.getReOrderQty());
      }
      MrpLineType mrpLineTypeProposal=this.getMrpLineTypeForProposal(minStockRules);
      this.createProposalMrpLine(product,mrpLineTypeProposal,reorderQty,mrpLine.getLocation(),mrpLine.getMaturityDate(),mrpLine.getMrpLineOriginList(),mrpLine.getRelatedToSelectName());
      doASecondPass=true;
    }
  }
  if (doASecondPass) {
    mrpRepository.save(mrp);
    this.checkInsufficientCumulativeQty(product);
  }
}

Fixed version (ground truth):
protected void checkInsufficientCumulativeQty(Product product) throws AxelorException {
  boolean doASecondPass=false;
  this.computeCumulativeQty(product);
  List<MrpLine> mrpLineList=mrpLineRepository.all().filter("String_Node_Str",mrp,product).order("String_Node_Str").order("String_Node_Str").order("String_Node_Str").order("String_Node_Str").fetch();
  for (  MrpLine mrpLine : mrpLineList) {
    BigDecimal cumulativeQty=mrpLine.getCumulativeQty();
    MrpLineType mrpLineType=mrpLine.getMrpLineType();
    boolean isProposalElement=this.isProposalElement(mrpLineType);
    BigDecimal minQty=mrpLine.getMinQty();
    if (mrpLine.getMrpLineType().getElementSelect() != MrpLineTypeRepository.ELEMENT_AVAILABLE_STOCK && (!isProposalElement || (isProposalElement && mrpLineType.getTypeSelect() == MrpLineTypeRepository.TYPE_OUT)) && cumulativeQty.compareTo(mrpLine.getMinQty()) == -1) {
      log.debug("String_Node_Str",cumulativeQty,minQty,product.getFullName(),mrpLine.getMaturityDate());
      BigDecimal reorderQty=minQty.subtract(cumulativeQty);
      MinStockRules minStockRules=minStockRulesService.getMinStockRules(product,mrpLine.getLocation(),MinStockRulesRepository.TYPE_FUTURE);
      if (minStockRules != null) {
        reorderQty=reorderQty.max(minStockRules.getReOrderQty());
      }
      MrpLineType mrpLineTypeProposal=this.getMrpLineTypeForProposal(minStockRules);
      this.createProposalMrpLine(product,mrpLineTypeProposal,reorderQty,mrpLine.getLocation(),mrpLine.getMaturityDate(),mrpLine.getMrpLineOriginList(),mrpLine.getRelatedToSelectName());
      doASecondPass=true;
      break;
    }
  }
  if (doASecondPass) {
    mrpRepository.save(mrp);
    this.checkInsufficientCumulativeQty(product);
  }
}