From 8d6027770ce366e9a283254c43be896d9f507935 Mon Sep 17 00:00:00 2001 From: miah <144297490+miah120@users.noreply.github.com> Date: Thu, 27 Aug 2026 11:39:23 +0000 Subject: [PATCH] fix: Account for on hand items when adding a recipe to a shopping list (#7912) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Arsène Reymond <66876397+p0lycarpio@users.noreply.github.com> --- .../services/household_services/shopping_lists.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mealie/services/household_services/shopping_lists.py b/mealie/services/household_services/shopping_lists.py index 831877ca2..4e2ceb718 100644 --- a/mealie/services/household_services/shopping_lists.py +++ b/mealie/services/household_services/shopping_lists.py @@ -355,6 +355,8 @@ class ShoppingListService: continue if isinstance(ingredient.food, IngredientFood): + if self._is_on_hand(list_id, ingredient.food): + continue food_id = ingredient.food.id label_id = ingredient.food.label_id else: @@ -410,6 +412,15 @@ class ShoppingListService: return list_items + def _is_on_hand(self, list_id: UUID4, food: IngredientFood) -> bool: + shopping_list = self.shopping_lists.get_one(list_id) + if shopping_list is None: + return False + household = self.repos.households.get_by_slug_or_id(shopping_list.household_id) + if household is None: + return False + return household.slug in food.households_with_ingredient_food + def add_recipe_ingredients_to_list( self, list_id: UUID4, @@ -472,6 +483,8 @@ class ShoppingListService: update_items: list[ShoppingListItemUpdateBulk] = [] delete_items: list[UUID4] = [] for item in shopping_list.list_items: + if item.food is not None and self._is_on_hand(list_id, item.food): + continue found = False refs = cast(list[ShoppingListItemRecipeRefOut], item.recipe_references)