Files
octopus/test_order_signals_existing.py
Andrey Smakotin 6c8af5ab2c fix: Улучшения системы ценообразования комплектов
Исправлены 4 проблемы:
1. Расчёт цены первого товара - улучшена валидация в getProductPrice и calculateFinalPrice
2. Отображение actual_price в Select2 вместо обычной цены
3. Количество по умолчанию = 1 для новых форм компонентов
4. Auto-select текста при клике на поле количества для удобства редактирования

Изменённые файлы:
- products/forms.py: добавлен __init__ в KitItemForm для quantity.initial = 1
- products/templates/includes/select2-product-init.html: обновлена formatSelectResult
- products/templates/productkit_create.html: добавлен focus handler для auto-select
- products/templates/productkit_edit.html: добавлен focus handler для auto-select

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 19:04:03 +03:00

90 lines
3.1 KiB
Python

import os
import sys
import django
from decimal import Decimal
sys.path.insert(0, 'C:/Users/team_/Desktop/test_qwen/myproject')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
django.setup()
from tenants.models import Client
from django.db import connection
from orders.models import Order
from inventory.models import Reservation, Sale, SaleBatchAllocation
grach = Client.objects.get(schema_name='grach')
connection.set_tenant(grach)
print("=== Order Signals Test with Existing Order ===\n")
# Получаем существующий заказ
try:
order = Order.objects.get(order_number__contains='ORD-20251027')
print("Found order: {}".format(order.order_number))
print("Customer: {}".format(order.customer.name))
print("Items in order: {}".format(order.items.count()))
# Показываем items
print("\nOrder items:")
for item in order.items.all():
product_name = item.product.name if item.product else item.product_kit.name
print(" - {} qty={} price={}".format(product_name, item.quantity, item.price))
# Проверяем резервирования
print("\n--- Checking Reservations ---\n")
reservations = Reservation.objects.filter(order_item__order=order)
print("Total reservations: {}".format(reservations.count()))
if reservations.exists():
for res in reservations:
print(" - qty={}, status={}, warehouse={}".format(
res.quantity, res.status, res.warehouse.name
))
else:
print(" No reservations found - might not have been created yet")
# Меняем статус на in_delivery
print("\n--- Changing status to in_delivery ---\n")
order.status = 'in_delivery'
order.save()
print("Order status changed to: {}".format(order.status))
# Проверяем продажи
print("\n--- Checking Sales ---\n")
sales = Sale.objects.filter(order=order)
print("Total sales: {}".format(sales.count()))
if sales.exists():
for sale in sales:
print("\nSale:")
print(" qty={}, price={}".format(sale.quantity, sale.sale_price))
print(" processed={}".format(sale.processed))
# Проверяем allocations
allocations = SaleBatchAllocation.objects.filter(sale=sale)
print(" Allocations: {}".format(allocations.count()))
for alloc in allocations:
print(" - batch qty={}, cost={}".format(
alloc.quantity, alloc.cost_price
))
else:
print(" No sales found")
# Проверяем финальный статус резервирования
print("\n--- Final Reservations Status ---\n")
final_reservations = Reservation.objects.filter(order_item__order=order)
for res in final_reservations:
print(" Reservation status: {}".format(res.status))
except Order.DoesNotExist:
print("ERROR: Order not found!")
except Exception as e:
print("ERROR: {}".format(str(e)))
import traceback
traceback.print_exc()