Search in sources :

Example 81 with PurchaseOrder

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);
    }
}
Also used : PurchaseOrderSupplierService(com.axelor.apps.suppliermanagement.service.PurchaseOrderSupplierService) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 82 with PurchaseOrder

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);
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) Company(com.axelor.apps.base.db.Company) PurchaseOrderSupplierLine(com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine) BlockingService(com.axelor.apps.base.service.BlockingService) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 83 with PurchaseOrder

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);
            }
        }
    }
}
Also used : ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) List(java.util.List) PriceList(com.axelor.apps.base.db.PriceList) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 84 with PurchaseOrder

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;
}
Also used : PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) Transactional(com.google.inject.persist.Transactional)

Aggregations

PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)84 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)26 AxelorException (com.axelor.exception.AxelorException)26 Transactional (com.google.inject.persist.Transactional)16 BigDecimal (java.math.BigDecimal)12 Company (com.axelor.apps.base.db.Company)11 Context (com.axelor.rpc.Context)10 Partner (com.axelor.apps.base.db.Partner)9 Product (com.axelor.apps.base.db.Product)9 ArrayList (java.util.ArrayList)9 Invoice (com.axelor.apps.account.db.Invoice)7 List (java.util.List)7 PurchaseOrderRepository (com.axelor.apps.purchase.db.repo.PurchaseOrderRepository)6 SaleOrder (com.axelor.apps.sale.db.SaleOrder)6 PurchaseOrderSupplychainService (com.axelor.apps.supplychain.service.PurchaseOrderSupplychainService)6 LocalDate (java.time.LocalDate)6 PurchaseOrderService (com.axelor.apps.purchase.service.PurchaseOrderService)5 StockMove (com.axelor.apps.stock.db.StockMove)5 Unit (com.axelor.apps.base.db.Unit)4 PurchaseOrderLineService (com.axelor.apps.purchase.service.PurchaseOrderLineService)4