use of com.axelor.apps.production.db.repo.BillOfMaterialRepository in project axelor-open-suite by axelor.
the class BillOfMaterialController method checkOriginalBillOfMaterial.
public void checkOriginalBillOfMaterial(ActionRequest request, ActionResponse response) {
BillOfMaterialRepository billOfMaterialRepository = Beans.get(BillOfMaterialRepository.class);
BillOfMaterial billOfMaterial = billOfMaterialRepository.find(request.getContext().asType(BillOfMaterial.class).getId());
List<BillOfMaterial> BillOfMaterialSet = Lists.newArrayList();
BillOfMaterialSet = billOfMaterialRepository.all().filter("self.originalBillOfMaterial = :origin").bind("origin", billOfMaterial).fetch();
String message;
if (!BillOfMaterialSet.isEmpty()) {
String existingVersions = "";
for (BillOfMaterial billOfMaterialVersion : BillOfMaterialSet) {
existingVersions += "<li>" + billOfMaterialVersion.getFullName() + "</li>";
}
message = String.format(I18n.get("This bill of materials already has the following versions : <br/><ul> %s </ul>And these versions may also have ones. Do you still wish to create a new one ?"), existingVersions);
} else {
message = I18n.get("Do you really wish to create a new version of this bill of materials ?");
}
response.setAlert(message);
}
Aggregations