use of com.axelor.apps.sale.db.Pack in project axelor-open-suite by axelor.
the class PackLineController method getPack.
public Pack getPack(Context context) {
Context parentContext = context.getParent();
PackLine packLine = context.asType(PackLine.class);
Pack pack = packLine.getPack();
if (parentContext != null && parentContext.getContextClass().equals(Pack.class)) {
pack = parentContext.asType(Pack.class);
}
return pack;
}
use of com.axelor.apps.sale.db.Pack in project axelor-open-suite by axelor.
the class SaleOrderController method addPack.
public void addPack(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
String saleOrderId = context.get("_id").toString();
SaleOrder saleOrder = Beans.get(SaleOrderRepository.class).find(Long.parseLong(saleOrderId));
@SuppressWarnings("unchecked") LinkedHashMap<String, Object> packMap = (LinkedHashMap<String, Object>) request.getContext().get("pack");
String packId = packMap.get("id").toString();
Pack pack = Beans.get(PackRepository.class).find(Long.parseLong(packId));
String qty = context.get("qty").toString();
BigDecimal packQty = new BigDecimal(qty);
saleOrder = Beans.get(SaleOrderService.class).addPack(saleOrder, pack, packQty);
response.setCanClose(true);
}
use of com.axelor.apps.sale.db.Pack in project axelor-open-suite by axelor.
the class PackLineController method getProductInformation.
public void getProductInformation(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
PackLine packLine = context.asType(PackLine.class);
Pack pack = this.getPack(context);
Product product = packLine.getProduct();
PackLineService packLineService = Beans.get(PackLineService.class);
if (product == null) {
packLine = packLineService.resetProductInformation(packLine);
response.setValues(packLine);
return;
}
try {
packLine = packLineService.computeProductInformation(pack, packLine);
response.setValues(packLine);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations