feat: упростить создание заказов и рефакторинг единиц измерения
- Добавить inline-редактирование цен в списке товаров - Оптимизировать карточки товаров в POS-терминале - Рефакторинг моделей единиц измерения - Миграция unit -> base_unit в SalesUnit - Улучшить UI форм создания/редактирования товаров Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -114,7 +114,7 @@ def search_products_and_variants(request):
|
||||
numeric_id = int(item_id)
|
||||
|
||||
if item_type == 'product':
|
||||
product = Product.objects.prefetch_related('sales_units__unit').get(id=numeric_id, status='active')
|
||||
product = Product.objects.prefetch_related('sales_units').get(id=numeric_id, status='active')
|
||||
|
||||
# Сериализация единиц продажи
|
||||
sales_units_data = []
|
||||
@@ -122,8 +122,6 @@ def search_products_and_variants(request):
|
||||
sales_units_data.append({
|
||||
'id': su.id,
|
||||
'name': su.name,
|
||||
'unit_code': su.unit.code,
|
||||
'unit_short_name': su.unit.short_name,
|
||||
'price': str(su.price),
|
||||
'sale_price': str(su.sale_price) if su.sale_price else None,
|
||||
'actual_price': str(su.actual_price),
|
||||
@@ -216,7 +214,7 @@ def search_products_and_variants(request):
|
||||
|
||||
if search_type in ['all', 'product']:
|
||||
# Показываем последние добавленные активные товары
|
||||
products_qs = Product.objects.filter(status='active').prefetch_related('sales_units__unit')
|
||||
products_qs = Product.objects.filter(status='active').prefetch_related('sales_units')
|
||||
# Применяем фильтры
|
||||
products_qs = _apply_product_filters(products_qs, category_id, tag_id, stock_status, warehouse_id, skip_stock_filter)
|
||||
products = products_qs.order_by('-created_at')[:page_size]
|
||||
@@ -235,8 +233,6 @@ def search_products_and_variants(request):
|
||||
sales_units_data.append({
|
||||
'id': su.id,
|
||||
'name': su.name,
|
||||
'unit_code': su.unit.code,
|
||||
'unit_short_name': su.unit.short_name,
|
||||
'price': str(su.price),
|
||||
'sale_price': str(su.sale_price) if su.sale_price else None,
|
||||
'actual_price': str(su.actual_price),
|
||||
@@ -365,7 +361,7 @@ def search_products_and_variants(request):
|
||||
products_query = _apply_product_filters(products_query, category_id, tag_id, stock_status, warehouse_id, skip_stock_filter)
|
||||
|
||||
# Добавляем prefetch для единиц продажи
|
||||
products_query = products_query.prefetch_related('sales_units__unit')
|
||||
products_query = products_query.prefetch_related('sales_units')
|
||||
|
||||
total_products = products_query.count()
|
||||
start = (page - 1) * page_size
|
||||
@@ -387,8 +383,6 @@ def search_products_and_variants(request):
|
||||
sales_units_data.append({
|
||||
'id': su.id,
|
||||
'name': su.name,
|
||||
'unit_code': su.unit.code,
|
||||
'unit_short_name': su.unit.short_name,
|
||||
'price': str(su.price),
|
||||
'sale_price': str(su.sale_price) if su.sale_price else None,
|
||||
'actual_price': str(su.actual_price),
|
||||
@@ -1422,7 +1416,7 @@ def get_product_sales_units_api(request, product_id):
|
||||
warehouse_id = request.GET.get('warehouse', '').strip()
|
||||
|
||||
# Получаем товар с prefetch единиц продажи
|
||||
product = Product.objects.prefetch_related('sales_units__unit').get(
|
||||
product = Product.objects.prefetch_related('sales_units').get(
|
||||
id=product_id, status='active'
|
||||
)
|
||||
|
||||
@@ -1448,8 +1442,6 @@ def get_product_sales_units_api(request, product_id):
|
||||
sales_units_data.append({
|
||||
'id': su.id,
|
||||
'name': su.name,
|
||||
'unit_code': su.unit.code,
|
||||
'unit_short_name': su.unit.short_name,
|
||||
'price': str(su.price),
|
||||
'sale_price': str(su.sale_price) if su.sale_price else None,
|
||||
'actual_price': str(su.actual_price),
|
||||
|
||||
Reference in New Issue
Block a user