added wherehouse json
This commit is contained in:
@@ -24,9 +24,8 @@ class Command(BaseCommand):
|
||||
product_name = item['product']['name']['uz']
|
||||
unit_name = item['unit']['name']['uz']
|
||||
warehouse_name = item['warehouse']['name']
|
||||
project_name = item['project']['name']
|
||||
project_name = item.get('project').get('name') if item.get('project') else None
|
||||
creator_name = item['creator']['full_name']
|
||||
|
||||
product = Product.objects.filter(name=product_name).first()
|
||||
unity = Unity.objects.filter(value=unit_name).first()
|
||||
wherehouse = WhereHouse.objects.filter(name=warehouse_name).first()
|
||||
@@ -35,7 +34,13 @@ class Command(BaseCommand):
|
||||
|
||||
delivery_date = datetime.strptime(item['delivery_date'], "%d.%m.%Y").date()
|
||||
created_at = datetime.strptime(item['created_at'], "%d.%m.%Y %H:%M")
|
||||
|
||||
if not product:
|
||||
product = Product.objects.create(
|
||||
name=product_name,
|
||||
product_code=item['product']['code'],
|
||||
type=item['product']['resource']['type'].upper(),
|
||||
unity=unity
|
||||
)
|
||||
Order.objects.update_or_create(
|
||||
status=item['status'].upper(),
|
||||
product=product,
|
||||
@@ -48,5 +53,6 @@ class Command(BaseCommand):
|
||||
created_at=created_at,
|
||||
date=delivery_date
|
||||
)
|
||||
break
|
||||
|
||||
self.stdout.write(self.style.SUCCESS("Orders imported successfully ✅"))
|
||||
|
||||
Reference in New Issue
Block a user