fiz um monte de coisa e criei um bug

This commit is contained in:
2025-01-15 11:04:27 -03:00
parent a2fd5d12e3
commit 43d9cd9c5b
20 changed files with 83 additions and 19 deletions

View File

@@ -2,13 +2,22 @@ from django.shortcuts import render
from comandas.models import Comanda, ProductComanda
from products.models import Product
from mesas.models import Mesa
from django.db.models import Count, F
from django.contrib.auth.models import User
def viewBalcao(request):
try:
comanda = Comanda.objects.get(name='VENDA BALCÃO')
except:
user = User.objects.get(id=request.user.id)
mesa = Mesa.objects.get(id=1)
comanda = Comanda(name='VENDA BALCÃO', mesa=mesa, user=user,status='CLOSED')
comanda.save()
comanda = Comanda.objects.get(name='VENDA BALCÃO')
consumo = ProductComanda.objects.filter(comanda=comanda.id)
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
quantidade=Count('product'),