diff --git a/modules/axelor-open-suite/axelor-purchase/src/main/java/com/axelor/apps/purchase/web/PurchaseRequestController.java b/modules/axelor-open-suite/axelor-purchase/src/main/java/com/axelor/apps/purchase/web/PurchaseRequestController.java index a978e6c..bb62044 100644 --- a/modules/axelor-open-suite/axelor-purchase/src/main/java/com/axelor/apps/purchase/web/PurchaseRequestController.java +++ b/modules/axelor-open-suite/axelor-purchase/src/main/java/com/axelor/apps/purchase/web/PurchaseRequestController.java @@ -78,6 +78,23 @@ public class PurchaseRequestController { .all() .filter("self.id in (?1)", requestIds) .fetch(); + // sophal + int condition = 0; + String message = ""; + for (PurchaseRequest result : purchaseRequests) { + if(result.getStatusSelect() != 5){ + condition = 1; + message = "purchase request not approved"; + break; + } + if(result.getPurchaseOrderSet().size() > 0){ + condition = 1; + message = "you have already generated this purchase request"; + break; + } + } + + if( condition == 0){ List purchaseRequestSeqs = purchaseRequests .stream() @@ -106,6 +123,11 @@ public class PurchaseRequestController { String.format( "self.id in (%s)", StringTool.getIdListString(purchaseOrderList))); response.setView(actionViewBuilder.map()); + + }else{ + response.setAlert(I18n.get(message)); + } + } catch (AxelorException e) { response.setFlash(e.getMessage()); }