diff --git a/cookbook/helper/shopping_helper.py b/cookbook/helper/shopping_helper.py
index 761f1e7c..2bd641fe 100644
--- a/cookbook/helper/shopping_helper.py
+++ b/cookbook/helper/shopping_helper.py
@@ -8,7 +8,7 @@ from django.utils import timezone
from django.utils.translation import gettext as _
from cookbook.helper.HelperFunctions import Round, str2bool
-from cookbook.models import (Ingredient, ShoppingListEntry, ShoppingListRecipe,
+from cookbook.models import (Ingredient, MealPlan, Recipe, ShoppingListEntry, ShoppingListRecipe,
SupermarketCategoryRelation)
from recipes import settings
@@ -45,6 +45,8 @@ class RecipeShoppingEditor():
self._kwargs = {**kwargs}
self.mealplan = self._kwargs.get('mealplan', None)
+ if type(self.mealplan) in [int, float]:
+ self.mealplan = MealPlan.objects.filter(id=self.mealplan, space=self.space)
self.id = self._kwargs.get('id', None)
self._shopping_list_recipe = self.get_shopping_list_recipe(self.id, self.created_by, self.space)
@@ -55,6 +57,8 @@ class RecipeShoppingEditor():
self.created_by = getattr(self._shopping_list_recipe.entries.first(), 'created_by', self.created_by)
self.recipe = getattr(self._shopping_list_recipe, 'recipe', None) or self._kwargs.get('recipe', None) or getattr(self.mealplan, 'recipe', None)
+ if type(self.recipe) in [int, float]:
+ self.recipe = Recipe.objects.filter(id=self.recipe, space=self.space)
try:
self.servings = float(self._kwargs.get('servings', None))
diff --git a/cookbook/views/api.py b/cookbook/views/api.py
index 8b6636ed..23d07088 100644
--- a/cookbook/views/api.py
+++ b/cookbook/views/api.py
@@ -644,7 +644,6 @@ class RecipeViewSet(viewsets.ModelViewSet):
schema = QueryParamAutoSchema()
def get_queryset(self):
-
if self.detail:
self.queryset = self.queryset.filter(space=self.request.space)
return super().get_queryset()
@@ -718,7 +717,8 @@ class RecipeViewSet(viewsets.ModelViewSet):
ingredients = request.data.get('ingredients', None)
servings = request.data.get('servings', None)
list_recipe = request.data.get('list_recipe', None)
- SLR = RecipeShoppingEditor(request.user, request.space, id=list_recipe, recipe=obj)
+ mealplan = request.data.get('mealplan', None)
+ SLR = RecipeShoppingEditor(request.user, request.space, id=list_recipe, recipe=obj, mealplan=mealplan)
content = {'msg': _(f'{obj.name} was added to the shopping list.')}
http_status = status.HTTP_204_NO_CONTENT
diff --git a/vue/src/components/GenericMultiselect.vue b/vue/src/components/GenericMultiselect.vue
index c6b4040d..be26f545 100644
--- a/vue/src/components/GenericMultiselect.vue
+++ b/vue/src/components/GenericMultiselect.vue
@@ -35,7 +35,7 @@ export default {
// this.Models and this.Actions inherited from ApiMixin
loading: false,
objects: [],
- selected_objects: [],
+ selected_objects: undefined,
}
},
props: {
@@ -80,7 +80,7 @@ export default {
this.selected_objects = newVal
},
clear: function (newVal, oldVal) {
- if (this.multiple) {
+ if (this.multiple || !this.initial_single_selection) {
this.selected_objects = []
} else {
this.selected_objects = undefined
@@ -100,10 +100,10 @@ export default {
return this.placeholder || this.model.name || this.$t("Search")
},
nothingSelected() {
- if (this.multiple) {
+ if (this.multiple || !this.initial_single_selection) {
return this.selected_objects.length === 0 && this.initial_selection.length === 0
} else {
- return !this.selected_objects && !this.initial_selection
+ return !this.selected_objects && !this.initial_single_selection
}
},
},
diff --git a/vue/src/components/MealPlanEditModal.vue b/vue/src/components/MealPlanEditModal.vue
index 6c3eea6c..cb1d7243 100644
--- a/vue/src/components/MealPlanEditModal.vue
+++ b/vue/src/components/MealPlanEditModal.vue
@@ -76,9 +76,13 @@
{{ $t("Share") }}