use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderController method backToValidatedStatus.
public void backToValidatedStatus(ActionRequest request, ActionResponse response) {
try {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
Beans.get(PurchaseOrderSupplychainService.class).updateToValidatedStatus(purchaseOrder);
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 PurchaseOrderController method checkPurchaseOrderAnalyticDistributionTemplate.
/**
* Called from purchase order form view when validating purchase order and analytic distribution
* is required from company's purchase config.
*
* @param request
* @param response
*/
public void checkPurchaseOrderAnalyticDistributionTemplate(ActionRequest request, ActionResponse response) {
try {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
List<String> productList = new ArrayList<String>();
for (PurchaseOrderLine purchaseOrderLine : purchaseOrder.getPurchaseOrderLineList()) {
if (purchaseOrderLine.getAnalyticDistributionTemplate() == null) {
productList.add(purchaseOrderLine.getProduct().getFullName());
}
}
if (productList != null && !productList.isEmpty()) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.PURCHASE_ORDER_ANALYTIC_DISTRIBUTION_ERROR), productList);
}
} catch (AxelorException e) {
TraceBackService.trace(response, e, ResponseMessageType.ERROR);
}
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderController method generateBudgetDistribution.
public void generateBudgetDistribution(ActionRequest request, ActionResponse response) {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
AppAccountService appAccountService = Beans.get(AppAccountService.class);
if (appAccountService.isApp("budget") && !appAccountService.getAppBudget().getManageMultiBudget()) {
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
Beans.get(PurchaseOrderSupplychainService.class).generateBudgetDistribution(purchaseOrder);
response.setValues(purchaseOrder);
}
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderInvoiceController method generateInvoice.
public void generateInvoice(ActionRequest request, ActionResponse response) {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
try {
Invoice invoice = Beans.get(PurchaseOrderInvoiceService.class).generateInvoice(purchaseOrder);
if (invoice != null) {
response.setReload(true);
response.setView(ActionView.define(I18n.get(IExceptionMessage.PO_INVOICE_2)).model(Invoice.class.getName()).add("form", "invoice-form").add("grid", "invoice-grid").param("search-filters", "customer-invoices-filters").domain("self.purchaseOrder.id = " + String.valueOf(invoice.getId())).domain("self.operationTypeSelect = " + String.valueOf(invoice.getOperationTypeSelect())).context("_operationTypeSelect", invoice.getOperationTypeSelect()).context("_showRecord", String.valueOf(invoice.getId())).map());
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method computeBudgetDistributionSumAmount.
public void computeBudgetDistributionSumAmount(ActionRequest request, ActionResponse response) {
PurchaseOrderLine purchaseOrderLine = request.getContext().asType(PurchaseOrderLine.class);
PurchaseOrder purchaseOrder = request.getContext().getParent().asType(PurchaseOrder.class);
Beans.get(PurchaseOrderLineServiceSupplychainImpl.class).computeBudgetDistributionSumAmount(purchaseOrderLine, purchaseOrder);
response.setValue("budgetDistributionSumAmount", purchaseOrderLine.getBudgetDistributionSumAmount());
response.setValue("budgetDistributionList", purchaseOrderLine.getBudgetDistributionList());
}
Aggregations