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 %}
+
+ |
+ {{ 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 }} |
+
+ {% endfor %}
+
+
+
+ |
+
+ {% 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
|