use ID in unit food import

This commit is contained in:
vabene1111 2024-02-18 21:38:52 +01:00
parent f085e7ff2f
commit 3a349b1bd2

View File

@ -202,7 +202,7 @@ class OpenDataImporter:
'supermarket_category_id': self.slug_id_cache['category'][self.data[datatype][k]['store_category']], 'supermarket_category_id': self.slug_id_cache['category'][self.data[datatype][k]['store_category']],
'fdc_id': re.sub(r'\D', '', self.data[datatype][k]['fdc_id']) if self.data[datatype][k]['fdc_id'] != '' else None, 'fdc_id': re.sub(r'\D', '', self.data[datatype][k]['fdc_id']) if self.data[datatype][k]['fdc_id'] != '' else None,
'open_data_slug': k, 'open_data_slug': k,
'properties_food_unit': unit_g, 'properties_food_unit_id': unit_g.id,
'space': self.request.space.id, 'space': self.request.space.id,
} }
@ -228,7 +228,7 @@ class OpenDataImporter:
total_count = 0 total_count = 0
if self.update_existing and len(update_list) > 0: if self.update_existing and len(update_list) > 0:
Food.objects.bulk_update(update_list, ['name', 'plural_name', 'properties_food_unit', 'supermarket_category_id', 'fdc_id', 'open_data_slug', ]) Food.objects.bulk_update(update_list, ['name', 'plural_name', 'properties_food_unit_id', 'supermarket_category_id', 'fdc_id', 'open_data_slug', ])
total_count += len(update_list) total_count += len(update_list)
if len(create_list) > 0: if len(create_list) > 0: