From 030d5ad19857cf3d7b9137b76488d40d96905c81 Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Sat, 3 Jan 2026 00:17:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B5=D0=B4=D0=B8=D0=BD=D0=B8=D1=86=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B4=D0=B0=D0=B6=D0=B8=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5=20=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit На странице детализации товара теперь отображается таблица с единицами продажи: название, единица измерения, коэффициент, цена, мин. количество и шаг. Единица по умолчанию выделена зелёным. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../templates/products/product_detail.html | 51 +++++++++++++++++-- myproject/products/views/product_views.py | 8 ++- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/myproject/products/templates/products/product_detail.html b/myproject/products/templates/products/product_detail.html index bf65a01..2b2eeaa 100644 --- a/myproject/products/templates/products/product_detail.html +++ b/myproject/products/templates/products/product_detail.html @@ -142,11 +142,11 @@ Остаток: - {{ product.total_free|floatformat:0 }} свободно + {{ product.total_free|floatformat:-2 }} свободно {% if product.total_reserved > 0 %} - {{ product.total_reserved|floatformat:0 }} в резерве + {{ product.total_reserved|floatformat:-2 }} в резерве {% endif %} - (всего: {{ product.total_available|floatformat:0 }}) + (всего: {{ product.total_available|floatformat:-2 }}) @@ -283,6 +283,51 @@ {% endif %} + {% if sales_units %} + + Единицы продажи: + +
+ + + + + + + + + + + + + {% for su in sales_units %} + + + + + + + + + {% endfor %} + +
НазваниеЕдиницаКоэфф.ЦенаМин. кол-воШаг
+ {{ su.name }} + {% if su.is_default %}По умолчанию{% endif %} + + {{ su.unit.short_name }} + {{ su.conversion_factor }} + {% if su.sale_price %} + {{ su.price }} + {{ su.sale_price }} руб. + {% else %} + {{ su.price }} руб. + {% endif %} + {{ su.min_quantity }}{{ su.quantity_step }}
+
+ + + {% endif %} Статус: diff --git a/myproject/products/views/product_views.py b/myproject/products/views/product_views.py index f59ded6..4a8bb57 100644 --- a/myproject/products/views/product_views.py +++ b/myproject/products/views/product_views.py @@ -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