Search in sources :

Example 1 with PurchaseOrderLineRepository

use of com.axelor.apps.purchase.db.repo.PurchaseOrderLineRepository in project axelor-open-suite by axelor.

the class PurchaseOrderLineProjectController method updateToInvoice.

/**
 * Invert value of 'toInvoice' field and save the record
 *
 * @param request
 * @param response
 */
@Transactional
public void updateToInvoice(ActionRequest request, ActionResponse response) {
    PurchaseOrderLineRepository purchaseOrderLineRepository = Beans.get(PurchaseOrderLineRepository.class);
    try {
        PurchaseOrderLine purchaseOrderLine = request.getContext().asType(PurchaseOrderLine.class);
        purchaseOrderLine = purchaseOrderLineRepository.find(purchaseOrderLine.getId());
        purchaseOrderLine.setToInvoice(!purchaseOrderLine.getToInvoice());
        purchaseOrderLineRepository.save(purchaseOrderLine);
        response.setValue("toInvoice", purchaseOrderLine.getToInvoice());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PurchaseOrderLineRepository(com.axelor.apps.purchase.db.repo.PurchaseOrderLineRepository) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) AxelorException(com.axelor.exception.AxelorException) Transactional(com.google.inject.persist.Transactional)

Aggregations

PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)1 PurchaseOrderLineRepository (com.axelor.apps.purchase.db.repo.PurchaseOrderLineRepository)1 AxelorException (com.axelor.exception.AxelorException)1 Transactional (com.google.inject.persist.Transactional)1