Fix: Units not showing in recipe list

Fix: Recipe update gave error
This commit is contained in:
Amritanshu 2014-04-29 16:38:31 +05:30
parent 1448120941
commit 35413166d4

View File

@ -132,6 +132,9 @@ def update(request):
recipe_cost += rate * quantity recipe_cost += rate * quantity
recipe_items.append(RecipeItem(None, product.id, quantity, ingredient_price)) recipe_items.append(RecipeItem(None, product.id, quantity, ingredient_price))
recipe.product.price = recipe_cost recipe.product.price = recipe_cost
for i in range(len(recipe.recipe_items), 0, -1):
recipe_item = recipe.recipe_items.pop()
DBSession.delete(recipe_item)
recipe.recipe_items = [] recipe.recipe_items = []
for recipe_item in recipe_items: for recipe_item in recipe_items:
recipe_item.recipe_id = recipe.id recipe_item.recipe_id = recipe.id
@ -209,10 +212,11 @@ def show_list(request):
'Price': cost_rate, 'Quantity': recipe_item.quantity}) 'Price': cost_rate, 'Quantity': recipe_item.quantity})
costing = 0 if item.sale_price == 0 else cost_price / item.sale_price costing = 0 if item.sale_price == 0 else cost_price / item.sale_price
current_costing = 0 if item.sale_price == 0 else current_cost_price / item.sale_price current_costing = 0 if item.sale_price == 0 else current_cost_price / item.sale_price
recipe = {'Name': item.product.name, 'Date': item.date.strftime('%d-%b-%Y'), 'SalePrice': item.sale_price, recipe = {'Name': item.product.name, 'Units': item.product.units, 'Date': item.date.strftime('%d-%b-%Y'),
'CostPrice': cost_price, 'CurrentCostPrice': current_cost_price, 'Costing': costing, 'SalePrice': item.sale_price, 'CostPrice': cost_price, 'CurrentCostPrice': current_cost_price,
'CurrentCosting': current_costing, 'IsSemi': item.product.is_semi, 'RecipeItems': recipe_items, 'Costing': costing, 'CurrentCosting': current_costing, 'IsSemi': item.product.is_semi,
'IsLatest': previous_product_id != item.product.id, 'Url': request.route_url('recipe_id', id=item.id)} 'RecipeItems': recipe_items, 'IsLatest': previous_product_id != item.product.id,
'Url': request.route_url('recipe_id', id=item.id)}
recipes.append(recipe) recipes.append(recipe)
previous_product_id = item.product.id previous_product_id = item.product.id
return recipes return recipes