From f34cfaeca04bd9230266a2c19da07509031bd446 Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Fri, 2 Jan 2026 14:40:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE:=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B5=D0=B7=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=BE=D0=B2=20=D0=B8=20=D1=80=D0=B0=D1=81=D1=87=D0=B5?= =?UTF-8?q?=D1=82=20quantity=5Freserved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Проблема: 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 отображаются корректно в базовых единицах --- myproject/inventory/models.py | 2 +- .../templates/inventory/debug_page.html | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/myproject/inventory/models.py b/myproject/inventory/models.py index 799f25b..849ead0 100644 --- a/myproject/inventory/models.py +++ b/myproject/inventory/models.py @@ -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 diff --git a/myproject/inventory/templates/inventory/debug_page.html b/myproject/inventory/templates/inventory/debug_page.html index dd7bef9..fbcded1 100644 --- a/myproject/inventory/templates/inventory/debug_page.html +++ b/myproject/inventory/templates/inventory/debug_page.html @@ -287,7 +287,9 @@ ID Товар Склад - Кол-во + Кол-во (ед.прод.) + Кол-во (базовые) + Единица продажи Статус Заказ Создан @@ -306,7 +308,21 @@ {{ res.id }} {{ res.product.name }} {{ res.warehouse.name }} - {{ res.quantity }} + {{ res.quantity }} + + {% if res.quantity_base %} + {{ res.quantity_base }} + {% else %} + - + {% endif %} + + + {% if res.sales_unit %} + {{ res.sales_unit.name }} + {% else %} + Базовая + {% endif %} + {% if res.status == 'reserved' %} Зарезервирован @@ -334,7 +350,7 @@ {% empty %} - Нет резервов + Нет резервов {% endfor %}