use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method getProductInformation.
public void getProductInformation(ActionRequest request, ActionResponse response) {
try {
PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
Context context = request.getContext();
PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
PurchaseOrder purchaseOrder = this.getPurchaseOrder(context);
Product product = purchaseOrderLine.getProduct();
this.resetProductInformation(response);
response.setValues(service.reset(purchaseOrderLine));
if (purchaseOrder == null || product == null) {
return;
}
purchaseOrderLine.setPurchaseOrder(purchaseOrder);
service.fill(purchaseOrderLine, purchaseOrder);
response.setValues(purchaseOrderLine);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method checkQty.
public void checkQty(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
PurchaseOrder purchaseOrder = getPurchaseOrder(context);
PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
service.checkMinQty(purchaseOrder, purchaseOrderLine, request, response);
service.checkMultipleQty(purchaseOrderLine, response);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method checkDifferentSupplier.
public void checkDifferentSupplier(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
PurchaseOrder purchaseOrder = getPurchaseOrder(context);
PurchaseOrderLineService service = Beans.get(PurchaseOrderLineService.class);
service.checkDifferentSupplier(purchaseOrder, purchaseOrderLine, response);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class QualityControlController method sendEmail.
@SuppressWarnings("unchecked")
public void sendEmail(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
QualityControlService qualityControlService = Beans.get(QualityControlService.class);
if (!ObjectUtils.isEmpty(context.get("_ids"))) {
List<Long> idList = Lists.transform((List) context.get("_ids"), new Function<Object, Long>() {
@Nullable
@Override
public Long apply(@Nullable Object input) {
return Long.parseLong(input.toString());
}
});
QualityControlRepository qualityControlRepo = Beans.get(QualityControlRepository.class);
for (Long id : idList) {
QualityControl qualityControl = qualityControlRepo.find(id);
if (qualityControl.getStatusSelect() == QualityControlRepository.STATUS_FINISHED) {
qualityControlService.sendEmail(qualityControl);
}
}
} else if (!ObjectUtils.isEmpty(context.get("id"))) {
QualityControl qualityControl = context.asType(QualityControl.class);
qualityControlService.sendEmail(qualityControl);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method supplierPartnerDefault.
/**
* Called from sale order line form, on product change and on sale supply select change
*
* @param request
* @param response
*/
public void supplierPartnerDefault(ActionRequest request, ActionResponse response) {
SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
if (saleOrderLine.getSaleSupplySelect() != SaleOrderLineRepository.SALE_SUPPLY_PURCHASE) {
return;
}
SaleOrder saleOrder = saleOrderLine.getSaleOrder();
if (saleOrder == null) {
Context parentContext = request.getContext().getParent();
if (parentContext == null) {
return;
}
saleOrder = parentContext.asType(SaleOrder.class);
}
if (saleOrder == null) {
return;
}
Partner supplierPartner = null;
if (saleOrderLine.getProduct() != null) {
supplierPartner = saleOrderLine.getProduct().getDefaultSupplierPartner();
}
if (supplierPartner != null) {
Blocking blocking = Beans.get(BlockingService.class).getBlocking(supplierPartner, saleOrder.getCompany(), BlockingRepository.PURCHASE_BLOCKING);
if (blocking != null) {
supplierPartner = null;
}
}
response.setValue("supplierPartner", supplierPartner);
}
Aggregations