From 9bd06cf5c650a5aaabbf302736d68adbdb7ebde2 Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Fri, 2 Jan 2026 18:01:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=BE=D0=BB=D0=B5=20quantity=20=D0=B2=20OrderIt?= =?UTF-8?q?em=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B6=D0=BA=D0=B8=20=D0=B4=D1=80=D0=BE=D0=B1=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Поле quantity изменено с PositiveIntegerField на DecimalField(max_digits=10, decimal_places=3) - Это необходимо для корректной работы с единицами продажи (например, 2.5 банча) - Создана миграция 0004_change_orderitem_quantity_to_decimal - Теперь POS корректно обрабатывает товары с дробными количествами в единицах продажи --- ...04_change_orderitem_quantity_to_decimal.py | 23 +++++++++++++++++++ myproject/orders/models/order_item.py | 7 ++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 myproject/orders/migrations/0004_change_orderitem_quantity_to_decimal.py diff --git a/myproject/orders/migrations/0004_change_orderitem_quantity_to_decimal.py b/myproject/orders/migrations/0004_change_orderitem_quantity_to_decimal.py new file mode 100644 index 0000000..8cd8664 --- /dev/null +++ b/myproject/orders/migrations/0004_change_orderitem_quantity_to_decimal.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.10 on 2026-01-02 14:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('orders', '0003_add_sales_unit_fields'), + ] + + operations = [ + migrations.AlterField( + model_name='historicalorderitem', + name='quantity', + field=models.DecimalField(decimal_places=3, default=1, help_text='Количество в единицах продажи (может быть дробным)', max_digits=10, verbose_name='Количество'), + ), + migrations.AlterField( + model_name='orderitem', + name='quantity', + field=models.DecimalField(decimal_places=3, default=1, help_text='Количество в единицах продажи (может быть дробным)', max_digits=10, verbose_name='Количество'), + ), + ] diff --git a/myproject/orders/models/order_item.py b/myproject/orders/models/order_item.py index ef74f7e..7b7e481 100644 --- a/myproject/orders/models/order_item.py +++ b/myproject/orders/models/order_item.py @@ -62,9 +62,12 @@ class OrderItem(models.Model): verbose_name="Артикул на момент заказа" ) - quantity = models.PositiveIntegerField( + quantity = models.DecimalField( + max_digits=10, + decimal_places=3, default=1, - verbose_name="Количество" + verbose_name="Количество", + help_text="Количество в единицах продажи (может быть дробным)" ) price = models.DecimalField(