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