use of com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine in project axelor-open-suite by axelor.
the class PurchaseOrderSupplierLineController method accept.
public void accept(ActionRequest request, ActionResponse response) {
PurchaseOrderSupplierLine purchaseOrderSupplierLine = Beans.get(PurchaseOrderSupplierLineRepository.class).find(request.getContext().asType(PurchaseOrderSupplierLine.class).getId());
if (purchaseOrderSupplierLine.getPurchaseOrderLine() == null && request.getContext().getParent() != null) {
purchaseOrderSupplierLine.setPurchaseOrderLine(Beans.get(PurchaseOrderLineRepository.class).find(request.getContext().getParent().asType(PurchaseOrderLine.class).getId()));
}
try {
Beans.get(PurchaseOrderSupplierLineService.class).accept(purchaseOrderSupplierLine);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine in project axelor-open-suite by axelor.
the class PurchaseOrderSupplierLineController method supplierPartnerDomain.
/**
* Called on supplier partner select. Set the domain for the field supplierPartner
*
* @param request
* @param response
*/
public void supplierPartnerDomain(ActionRequest request, ActionResponse response) {
PurchaseOrderSupplierLine purchaseOrderSupplierLine = request.getContext().asType(PurchaseOrderSupplierLine.class);
PurchaseOrderLine purchaseOrderLine = purchaseOrderSupplierLine.getPurchaseOrderLine();
if (purchaseOrderLine == null) {
purchaseOrderLine = request.getContext().getParent().asType(PurchaseOrderLine.class);
}
PurchaseOrder purchaseOrder = request.getContext().getParent().getParent().asType(PurchaseOrder.class);
if (purchaseOrder.getId() != null) {
purchaseOrder = purchaseOrderLine.getPurchaseOrder();
}
Company company = purchaseOrder.getCompany();
String domain = "";
if (Beans.get(AppPurchaseService.class).getAppPurchase().getManageSupplierCatalog() && purchaseOrderLine.getProduct() != null && !purchaseOrderLine.getProduct().getSupplierCatalogList().isEmpty()) {
domain += "self.id != " + company.getPartner().getId() + " AND self.id IN " + purchaseOrderLine.getProduct().getSupplierCatalogList().stream().map(s -> s.getSupplierPartner().getId()).collect(Collectors.toList()).toString().replace('[', '(').replace(']', ')');
String blockedPartnerQuery = Beans.get(BlockingService.class).listOfBlockedPartner(company, BlockingRepository.PURCHASE_BLOCKING);
if (!Strings.isNullOrEmpty(blockedPartnerQuery)) {
domain += String.format(" AND self.id NOT in (%s)", blockedPartnerQuery);
}
} else {
domain += "self.id = 0";
}
domain += " AND " + company.getId() + " in (SELECT id FROM self.companySet)";
response.setAttr("supplierPartner", "domain", domain);
}
Aggregations