use of com.axelor.apps.base.db.repo.ProductRepository in project axelor-open-suite by axelor.
the class PartnerSaleServiceImpl method getProductBoughtByCustomer.
public List<Product> getProductBoughtByCustomer(Partner customer) {
String domain = "self.id in (SELECT line.product" + " FROM SaleOrderLine line join SaleOrder sale on line.saleOrder = sale.id" + " WHERE sale.statusSelect IN (" + SaleOrderRepository.STATUS_ORDER_CONFIRMED + ", " + SaleOrderRepository.STATUS_ORDER_COMPLETED + ")" + " AND sale.clientPartner = " + customer.getId() + ")";
ProductRepository productRepo = Beans.get(ProductRepository.class);
List<Product> productList = productRepo.all().filter(domain).fetch();
return productList;
}
use of com.axelor.apps.base.db.repo.ProductRepository in project axelor-open-suite by axelor.
the class ProductSupplierServiceImpl method addOnCatalog.
@Transactional(rollbackOn = { Exception.class })
@Override
public Product addOnCatalog(ProductSupplier productSupplier) throws AxelorException {
ProductRepository productRepo = Beans.get(ProductRepository.class);
if (productSupplier.getProductCode() == null) {
throw new AxelorException(productSupplier, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get(IExceptionMessage.PRODUCT_SUPPLIER_NO_CODE));
}
if (productSupplier.getProductName() == null) {
throw new AxelorException(productSupplier, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get(IExceptionMessage.PRODUCT_SUPPLIER_NO_NAME), productSupplier.getProductCode());
}
if (productRepo.findByCode(productSupplier.getProductCode()) != null) {
throw new AxelorException(productSupplier, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PRODUCT_SUPPLIER_SAME_CODE));
}
Product productCreated = createProductFromProductSupplier(productSupplier);
productSupplier.setProductCreated(productCreated);
Beans.get(ProductSupplierRepository.class).save(productSupplier);
return productCreated;
}
Aggregations