use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderController method generateSuppliersPurchaseOrder.
public void generateSuppliersPurchaseOrder(ActionRequest request, ActionResponse response) {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
try {
Beans.get(PurchaseOrderSupplierService.class).generateSuppliersPurchaseOrder(Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId()));
response.setFlash(I18n.get(IExceptionMessage.PURCHASE_ORDER_1));
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.purchase.db.PurchaseOrder 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);
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderServiceProductionImpl method setMergedPurchaseOrderForManufOrder.
@SuppressWarnings("unchecked")
private void setMergedPurchaseOrderForManufOrder(PurchaseOrder mergedPurchaseOrder, List<PurchaseOrder> purchaseOrderList) {
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageOutsourcing()) {
ManufOrderRepository manufOrderRepository = Beans.get(ManufOrderRepository.class);
for (PurchaseOrder purchaseOrder : purchaseOrderList) {
List<ManufOrder> manufOrderList = (List<ManufOrder>) manufOrderRepository.all().filter("self.purchaseOrder.id = ?1", purchaseOrder.getId());
for (ManufOrder manufOrder : manufOrderList) {
manufOrder.setPurchaseOrder(mergedPurchaseOrder);
manufOrderRepository.save(manufOrder);
}
}
}
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderServiceProductionImpl method mergePurchaseOrders.
@Override
@Transactional
public PurchaseOrder mergePurchaseOrders(List<PurchaseOrder> purchaseOrderList, Currency currency, Partner supplierPartner, Company company, Partner contactPartner, PriceList priceList, TradingName tradingName) throws AxelorException {
PurchaseOrder mergedPurchaseOrder = super.mergePurchaseOrders(purchaseOrderList, currency, supplierPartner, company, contactPartner, priceList, tradingName);
this.setMergedPurchaseOrderForManufOrder(mergedPurchaseOrder, purchaseOrderList);
return mergedPurchaseOrder;
}
Aggregations