Auto-create order statuses on tenant activation

Add OrderStatusService.create_default_statuses() call during tenant
registration approval. Creates 8 system order statuses (draft, new,
confirmed, in_assembly, in_delivery, completed, return, cancelled).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-23 01:14:28 +03:00
parent d3d3c23695
commit 4a9df60f91

View File

@@ -299,6 +299,17 @@ class TenantRegistrationAdmin(admin.ModelAdmin):
logger.error(f"Ошибка при создании системного клиента: {e}", exc_info=True)
# Не прерываем процесс, т.к. это не критично
# Создаем системные статусы заказов
logger.info(f"Создание системных статусов заказов для тенанта: {client.id}")
from orders.services.order_status_service import OrderStatusService
try:
OrderStatusService.create_default_statuses()
logger.info("Системные статусы заказов успешно созданы")
except Exception as e:
logger.error(f"Ошибка при создании статусов заказов: {e}", exc_info=True)
# Не прерываем процесс, т.к. это не критично
# Возвращаемся в public схему
connection.set_schema_to_public()