Search in sources :

Example 1 with SaleOrderLineRepository

use of com.axelor.apps.sale.db.repo.SaleOrderLineRepository in project axelor-open-suite by axelor.

the class SaleOrderLineProjectController method updateToInvoice.

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

Aggregations

SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)1 SaleOrderLineRepository (com.axelor.apps.sale.db.repo.SaleOrderLineRepository)1 AxelorException (com.axelor.exception.AxelorException)1 Transactional (com.google.inject.persist.Transactional)1