Add stock availability display to product list and detail views

- Add total_available, total_reserved, total_free annotations to product queries
- Display free stock (green/red) with reserved count in product list
- Show detailed stock info in product detail page (moved to top)
- Make reservation count clickable to view filtered reservations
- Add product filter support to ReservationListView
- Add product link in reservation list for easy navigation

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-23 00:31:38 +03:00
parent 856e1ca4c1
commit d3d3c23695
5 changed files with 76 additions and 29 deletions

View File

@@ -139,6 +139,16 @@
<th>Артикул:</th>
<td>{{ product.sku }}</td>
</tr>
<tr>
<th>Остаток:</th>
<td>
<strong class="fs-5 {% if product.total_free > 0 %}text-success{% else %}text-danger{% endif %}">{{ product.total_free|floatformat:0 }}</strong> <span class="text-muted">свободно</span>
{% if product.total_reserved > 0 %}
<a href="{% url 'inventory:reservation-list' %}?product={{ product.pk }}" class="ms-2 text-warning text-decoration-none" target="_blank" title="Посмотреть резервы"><i class="bi bi-lock"></i> {{ product.total_reserved|floatformat:0 }} в резерве <i class="bi bi-box-arrow-up-right small"></i></a>
{% endif %}
<span class="ms-2 text-muted small">(всего: {{ product.total_available|floatformat:0 }})</span>
</td>
</tr>
<tr>
<th>Описание:</th>
<td>{{ product.description|default:"-" }}</td>
@@ -266,16 +276,6 @@
{% endif %}
</td>
</tr>
<tr>
<th>В наличии:</th>
<td>
{% if product.in_stock %}
<span class="badge bg-success"><i class="bi bi-check-circle"></i> Да, в наличии</span>
{% else %}
<span class="badge bg-danger"><i class="bi bi-x-circle"></i> Нет, закончился</span>
{% endif %}
</td>
</tr>
<tr>
<th>Статус:</th>
<td>

View File

@@ -131,7 +131,7 @@
<th>Категория</th>
<th style="width: 150px;">Теги</th>
<th style="width: 130px;">Цена</th>
<th style="width: 100px;">В наличии</th>
<th style="width: 120px;">Остаток</th>
<th style="width: 100px;">Статус</th>
<th style="width: 150px;">Действия</th>
</tr>
@@ -193,10 +193,8 @@
</td>
<td>
{% if item.item_type == 'product' %}
{% if item.in_stock %}
<span class="badge bg-success"><i class="bi bi-check-circle"></i> Да</span>
{% else %}
<span class="badge bg-danger"><i class="bi bi-x-circle"></i> Нет</span>
<strong class="{% if item.total_free > 0 %}text-success{% else %}text-danger{% endif %}">{{ item.total_free|floatformat:0 }}</strong>{% if item.total_reserved > 0 %}<small class="text-muted"> / {{ item.total_available|floatformat:0 }}</small>
<small class="text-warning d-block">{{ item.total_reserved|floatformat:0 }} в резерве</small>
{% endif %}
{% else %}
<span class="text-muted">-</span>