Добавлено отображение единиц продажи на странице товара

На странице детализации товара теперь отображается таблица с единицами
продажи: название, единица измерения, коэффициент, цена, мин. количество
и шаг. Единица по умолчанию выделена зелёным.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-03 00:17:14 +03:00
parent d28a845664
commit 030d5ad198
2 changed files with 54 additions and 5 deletions

View File

@@ -167,7 +167,8 @@ class ProductDetailView(LoginRequiredMixin, ManagerOwnerRequiredMixin, DetailVie
return super().get_queryset().prefetch_related(
'photos',
'categories',
'tags'
'tags',
'sales_units__unit'
).annotate(
total_available=total_available,
total_reserved=total_reserved,
@@ -185,7 +186,10 @@ class ProductDetailView(LoginRequiredMixin, ManagerOwnerRequiredMixin, DetailVie
# Кешируем cost_price_details, чтобы не делать множественные запросы к БД
from ..services.cost_calculator import ProductCostCalculator
context['cost_price_details'] = ProductCostCalculator.get_cost_details(self.object)
# Единицы продажи (активные, отсортированные)
context['sales_units'] = self.object.sales_units.filter(is_active=True).order_by('position', 'name')
return context