def subproduct_add(request, bill_id, sold_id, product_id): """Add a product to a bill. If this product contains others products, we have to add them too.""" product = get_object_or_404(Produit, pk=product_id) sold = ProduitVendu(produit=product) sold.made_with = sold.produit.categorie sold.save() menu = get_object_or_404(ProduitVendu, pk=sold_id) menu.contient.add(sold) request.session['menu_id'] = menu.id return redirect('bill_sold_working', bill_id, sold.id)
def subproduct_add(request, bill_id, sold_id, product_id): """ Add a product to a bill. If this product contains others products, we have to add them too. TODO :param HttpRequest request: :param bill_id: :type bill_id: :param sold_id: :type sold_id: :param product_id: :type product_id: """ product = get_object_or_404(Produit, pk=product_id) sold = ProduitVendu(produit=product) sold.made_with = sold.produit.categorie sold.save() menu = get_object_or_404(ProduitVendu, pk=sold_id) menu.contient.add(sold) request.session['menu_id'] = menu.id return sold_working(request, bill_id, sold.id)
def subproduct_add(request, bill_id, sold_id, product_id): """Add a product to a bill. If this product contains others products, we have to add them too.""" product = get_object_or_404(Produit, pk=product_id) product_sell = ProduitVendu(produit=product) product_sell.made_with = product_sell.produit.categorie product_sell.save() menu = get_object_or_404(ProduitVendu, pk=sold_id) menu.contient.add(product_sell) if product.choix_cuisson: redirect_url = '/bill/%s/sold/%s/%s/cooking/' % (bill_id, menu.id, product_sell.id) return HttpResponseRedirect(redirect_url) category = menu.getFreeCategorie() if category: redirect_url = '/bill/%s/sold/%s/category/%s/select/' % (bill_id, menu.id, category.id) return HttpResponseRedirect(redirect_url) redirect_url = '/bill/%s/category/%s/' % (bill_id, menu.produit.categorie.id) return HttpResponseRedirect(redirect_url)