fix: actualizando precios al importar productos.

This commit is contained in:
2024-06-29 17:20:01 -05:00
parent 64a9b75ad7
commit 524626aea3
2 changed files with 35 additions and 7 deletions

View File

@@ -59,13 +59,13 @@ def handle_import_products_file(csv_file):
data = io.StringIO(csv_file.read().decode('utf-8'))
reader = csv.DictReader(data, quotechar='"')
for row in reader:
product, _ = Product.objects.get_or_create(
product, created = Product.objects.update_or_create(
name=row['producto'],
defaults={'price': row['precio']}
defaults={
'price': row['precio'],
'measuring_unit': row['unidad'],
}
)
product.price = row['precio']
product.measuring_unit = row['unidad']
product.save()
categories = [n.strip() for n in row["categorias"].split("&")]
for category in categories: