summaryrefslogtreecommitdiff
path: root/core/management/commands/import_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/management/commands/import_data.py')
-rw-r--r--core/management/commands/import_data.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/core/management/commands/import_data.py b/core/management/commands/import_data.py
index f78f27e..cf1d4b6 100644
--- a/core/management/commands/import_data.py
+++ b/core/management/commands/import_data.py
@@ -79,6 +79,8 @@ class Command(BaseCommand):
else PickupPoint.objects.first()
)
+ status = "completed" if row.pop("status", None) == "Завершен" else "new"
+
user_obj = User.objects.get(full_name=row["client_name"])
order, created = Order.objects.get_or_create(
id=row["id"],
@@ -86,16 +88,14 @@ class Command(BaseCommand):
user=user_obj,
delivery_date=delivery_date,
order_date=order_date,
+ status=status,
defaults=row,
)
if created and items_string:
items = items_string.split(", ")
for i in range(0, len(items), 2):
art = items[i].strip()
- try:
- prod = Products.get(article=art)
- OrderItem.objects.create(
- order=order, product=prod, count=int(items[i+1])
- )
- except Exception:
- pass
+ prod = Product.objects.get(article=art)
+ OrderItem.objects.create(
+ order=order, product=prod, count=int(items[i+1])
+ )