fix
This commit is contained in:
@@ -7,6 +7,7 @@ from core.apps.orders.models import Order
|
||||
class OrderAdmin(admin.ModelAdmin):
|
||||
list_display = ['id', 'product', 'wherehouse', 'currency', 'counterparty']
|
||||
list_filter = ['counterparty']
|
||||
search_fields = ['parties__number']
|
||||
|
||||
# # Statuslar: {'ORDERED', 'PARTIALLY_RECIEVED', 'pending', "open", "buying", "rejected", "recieved", "passive"}
|
||||
# open -> yangi == NEW
|
||||
|
||||
@@ -26,6 +26,9 @@ class PartyAdmin(admin.ModelAdmin):
|
||||
"number", "orders__counterparty__name"
|
||||
]
|
||||
|
||||
def get_queryset(self, request):
|
||||
return super().get_queryset(request).select_related('party_amount')
|
||||
|
||||
|
||||
@admin.register(PartyAmount)
|
||||
class PartyAmountAdmin(admin.ModelAdmin):
|
||||
|
||||
@@ -25,11 +25,10 @@ headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("ids", type=list)
|
||||
parser.add_argument("ids", type=int, nargs="+")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
for page in range(1,6):
|
||||
data = options['ids']
|
||||
ids = options['ids']
|
||||
statuses = {
|
||||
"open": "NEW",
|
||||
"ordered": "PARTY_IS_MADE",
|
||||
@@ -41,10 +40,10 @@ class Command(BaseCommand):
|
||||
"partially_recieved": "PROCESS"
|
||||
}
|
||||
|
||||
for id in data:
|
||||
for id in ids:
|
||||
url = f"https://backend.app.uyqur.uz/main/supply/order-view?id={id}"
|
||||
res = requests.get(url, headers=headers)
|
||||
data = res.json()["data"]
|
||||
data = res.json()['data']
|
||||
user = None
|
||||
if data.get("agent"):
|
||||
user = User.objects.filter(full_name=data["agent"]["full_name"]).first()
|
||||
|
||||
@@ -76,6 +76,7 @@ class Party(BaseModel):
|
||||
for order in self.orders.all():
|
||||
count += 1
|
||||
percentage += order.completion_percentage
|
||||
if percentage > 0 and count > 0:
|
||||
self.process = percentage / count
|
||||
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user