Исправлено: отображение резервов и расчет quantity_reserved

- Проблема: debug_page показывал quantity вместо quantity_base для резервов

- Проблема: Stock.refresh_from_batches() суммировал quantity вместо quantity_base

- Решение:

  - debug_page.html: добавлены колонки для единиц продажи и базовых единиц

  - debug_page.html: теперь показывается quantity (ед.прод.) и quantity_base (базовые)

  - models.py: Stock.refresh_from_batches() теперь суммирует quantity_base

- Теперь quantity_reserved и quantity_free отображаются корректно в базовых единицах
This commit is contained in:
2026-01-02 14:40:53 +03:00
parent 25f2ba6b82
commit f34cfaeca0
2 changed files with 20 additions and 4 deletions

View File

@@ -739,7 +739,7 @@ class Stock(models.Model):
product=self.product,
warehouse=self.warehouse,
status='reserved'
).aggregate(models.Sum('quantity'))['quantity__sum'] or Decimal('0')
).aggregate(models.Sum('quantity_base'))['quantity_base__sum'] or Decimal('0')
self.quantity_available = total_qty
self.quantity_reserved = total_reserved

View File

@@ -287,7 +287,9 @@
<th>ID</th>
<th>Товар</th>
<th>Склад</th>
<th>Кол-во</th>
<th>Кол-во (ед.прод.)</th>
<th>Кол-во (базовые)</th>
<th>Единица продажи</th>
<th>Статус</th>
<th>Заказ</th>
<th>Создан</th>
@@ -306,7 +308,21 @@
<td>{{ res.id }}</td>
<td><strong>{{ res.product.name }}</strong></td>
<td>{{ res.warehouse.name }}</td>
<td><span class="badge bg-dark">{{ res.quantity }}</span></td>
<td><span class="badge bg-secondary">{{ res.quantity }}</span></td>
<td>
{% if res.quantity_base %}
<span class="badge bg-dark">{{ res.quantity_base }}</span>
{% else %}
<span class="text-danger">-</span>
{% endif %}
</td>
<td>
{% if res.sales_unit %}
<small>{{ res.sales_unit.name }}</small>
{% else %}
<span class="text-muted">Базовая</span>
{% endif %}
</td>
<td>
{% if res.status == 'reserved' %}
<span class="badge bg-warning text-dark">Зарезервирован</span>
@@ -334,7 +350,7 @@
</td>
</tr>
{% empty %}
<tr><td colspan="9" class="text-center text-muted">Нет резервов</td></tr>
<tr><td colspan="11" class="text-center text-muted">Нет резервов</td></tr>
{% endfor %}
</tbody>
</table>