Self hosted FLOSS fitness/workout, nutrition and weight tracker
fix: relax product_name check for Open Food Facts import
Ewin7e0bda16a66eb
diff --git a/wger/nutrition/extract_info/off.py b/wger/nutrition/extract_info/off.pyindex f5e0ea9ab..a80137283 100644--- a/wger/nutrition/extract_info/off.py+++ b/wger/nutrition/extract_info/off.py@@ -28,7 +28,6 @@ from wger.utils.constants import ODBL_LICENSE_IDOFF_REQUIRED_TOP_LEVEL = [- 'product_name','code','nutriments',]@@ -116,7 +115,18 @@ def extract_info_from_off(product_data: dict, language: int) -> IngredientData:raise KeyError('Missing required nutrition key')# Basics- name = product_data.get('product_name', '')+ # Try standard product_name or english fallback+ name = product_data.get('product_name') or product_data.get('product_name_en')+ # Fallback to ANY localized product name+ if not name:+ for key, value in product_data.items():+ if key.startswith('product_name_') and value:+ name = value+ break+ # If product name is still not found, throw error+ if not name:+ raise KeyError('Missing required product name')+common_name = product_data.get('generic_name', '')# If the energy is not available in kcal, convert from kJ