diff --git a/cookbook/helper/shopping_helper.py b/cookbook/helper/shopping_helper.py index 31a3f3cde..e19de68eb 100644 --- a/cookbook/helper/shopping_helper.py +++ b/cookbook/helper/shopping_helper.py @@ -59,7 +59,7 @@ def list_from_recipe(list_recipe=None, recipe=None, mealplan=None, servings=None try: servings = float(servings) - except ValueError: + except (ValueError, TypeError): servings = getattr(mealplan, 'servings', 1.0) servings_factor = servings / r.servings @@ -139,7 +139,7 @@ def list_from_recipe(list_recipe=None, recipe=None, mealplan=None, servings=None sle.save() # add any missing Entrys - for i in [x for x in add_ingredients if not x.food.ignore_shopping]: + for i in [x for x in add_ingredients if x.food and not x.food.ignore_shopping]: ShoppingListEntry.objects.create( list_recipe=list_recipe, diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 63b85171c..53ab324f8 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -628,7 +628,7 @@ class MealPlanSerializer(SpacedModelSerializer, WritableNestedModelSerializer): validated_data['created_by'] = self.context['request'].user mealplan = super().create(validated_data) if self.context['request'].data.get('addshopping', False): - list_from_recipe(mealplan=mealplan, space=validated_data['space'], created_by=validated_data['created_by']) + list_from_recipe(mealplan=mealplan, servings=validated_data['servings'], created_by=validated_data['created_by'], space=validated_data['space']) return mealplan class Meta: diff --git a/vue/src/components/RecipeContextMenu.vue b/vue/src/components/RecipeContextMenu.vue index a225dd77a..6e43470b8 100644 --- a/vue/src/components/RecipeContextMenu.vue +++ b/vue/src/components/RecipeContextMenu.vue @@ -125,6 +125,7 @@ export default { entry.date = moment(entry.date).format("YYYY-MM-DD") let apiClient = new ApiApiFactory() + console.log("etnry", entry) apiClient .createMealPlan(entry) diff --git a/vue/src/components/ShoppingLineItem.vue b/vue/src/components/ShoppingLineItem.vue index a47d1d92b..5d3ff35a9 100644 --- a/vue/src/components/ShoppingLineItem.vue +++ b/vue/src/components/ShoppingLineItem.vue @@ -1,7 +1,4 @@