Добавлена возможность выбора анонимного системного клиента в форме заказа

- Убрана фильтрация системного клиента из результатов поиска (api_search_customers)
- Добавлен флаг is_system_customer в результаты API поиска
- Создан новый API endpoint api_get_system_customer для быстрого получения системного клиента
- Добавлена кнопка 'Аноним' для быстрого выбора системного клиента
- Системный клиент выделяется жёлтым цветом и иконкой инкогнито в выпадающем списке
- Улучшена компактность результатов поиска (уменьшен шрифт до 13px)
- Изменены пропорции полей: клиент 9 колонок, статус 3 колонки (было 6:6)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-15 12:54:56 +03:00
parent c7e03d258b
commit 2ef537fff6
4 changed files with 218 additions and 35 deletions

View File

@@ -21,5 +21,6 @@ urlpatterns = [
# AJAX API endpoints
path('api/search/', views.api_search_customers, name='api-search-customers'),
path('api/create/', views.api_create_customer, name='api-create-customer'),
path('api/system/', views.api_get_system_customer, name='api-get-system-customer'),
path('<int:pk>/api/update/', views.api_update_customer, name='api-update-customer'),
]

View File

@@ -376,6 +376,39 @@ def build_customer_search_query(query, strategy, search_value):
return Q(name__icontains=query)
@require_http_methods(["GET"])
def api_get_system_customer(request):
"""
AJAX endpoint для получения системного (анонимного) клиента.
Возвращает JSON с данными системного клиента:
{
"success": true,
"customer": {
"id": 1,
"text": "АНОНИМНЫЙ ПОКУПАТЕЛЬ (POS)",
"name": "АНОНИМНЫЙ ПОКУПАТЕЛЬ (POS)",
"phone": "",
"email": "system@pos.customer",
"is_system_customer": true
}
}
"""
system_customer, _ = Customer.get_or_create_system_customer()
return JsonResponse({
'success': True,
'customer': {
'id': system_customer.pk,
'text': system_customer.name,
'name': system_customer.name,
'phone': str(system_customer.phone) if system_customer.phone else '',
'email': system_customer.email,
'is_system_customer': True,
}
})
@require_http_methods(["GET"])
def api_search_customers(request):
"""
@@ -456,8 +489,8 @@ def api_search_customers(request):
if channel_matches:
q_objects |= Q(pk__in=channel_matches)
# Исключаем системного клиента из результатов поиска
customers = Customer.objects.filter(q_objects).filter(is_system_customer=False).distinct().order_by('name')[:20]
# Включаем всех клиентов, включая системного (для возможности выбора в заказах)
customers = Customer.objects.filter(q_objects).distinct().order_by('name')[:20]
results = []
@@ -475,6 +508,7 @@ def api_search_customers(request):
'phone': phone_display,
'email': customer.email,
'wallet_balance': float(customer.wallet_balance),
'is_system_customer': customer.is_system_customer,
})
# Если ничего не найдено, предлагаем создать нового клиента