I try to show a list of product record in inventory models and link to a vendor.
but I try to show the last record for each different product and its balance quatity.
in my case, I’ve 3 vendors. for each product sale or purchase I save it. so a vendor can manage his own stock. vendor A can pruchase product1, product 2 and next day do the same. the vendor 2 can purchase the same product1 and product3.
so I wanna know how to show onqty balance for product 1 for vendeur 1 do the same for product2 etc.
vendor = Vendor.objects.filter(user=request.user)
q = Inventory.objects.values('product').annotate(latest_id=Max('id'))
stock = Inventory.objects.filter(id__in= for product in q],vendor__in=vendor)
context = {
"vendor":vendor,
"stock": stock,
}
return render(request, 'core/dashboard.html', context)