Add new models UnitOfMeasure and ProductSalesUnit to enable selling products in different units (e.g., bunches, kg). Update Product model with base_unit field and methods for unit conversions and availability. Extend Sale, Reservation, and OrderItem models with sales_unit fields and snapshots. Modify SaleProcessor to handle quantity conversions. Include admin interfaces for managing units. Add corresponding database migrations.
56 lines
3.2 KiB
Python
56 lines
3.2 KiB
Python
# Generated by Django 5.0.10 on 2026-01-01 21:29
|
||
|
||
import django.db.models.deletion
|
||
from django.db import migrations, models
|
||
|
||
|
||
class Migration(migrations.Migration):
|
||
|
||
dependencies = [
|
||
('orders', '0002_initial'),
|
||
('products', '0006_populate_unit_of_measure'),
|
||
]
|
||
|
||
operations = [
|
||
migrations.AddField(
|
||
model_name='historicalorderitem',
|
||
name='conversion_factor_snapshot',
|
||
field=models.DecimalField(blank=True, decimal_places=6, help_text='Коэффициент конверсии на момент заказа', max_digits=15, null=True, verbose_name='Коэффициент конверсии (snapshot)'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='historicalorderitem',
|
||
name='quantity_in_base_units',
|
||
field=models.DecimalField(blank=True, decimal_places=6, help_text='Количество в единицах хранения товара (для списания со склада)', max_digits=10, null=True, verbose_name='Количество в базовых единицах'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='historicalorderitem',
|
||
name='sales_unit',
|
||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='products.productsalesunit', verbose_name='Единица продажи'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='historicalorderitem',
|
||
name='unit_name_snapshot',
|
||
field=models.CharField(blank=True, default='', help_text='Название единицы продажи на момент заказа', max_length=100, verbose_name='Название единицы (snapshot)'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='orderitem',
|
||
name='conversion_factor_snapshot',
|
||
field=models.DecimalField(blank=True, decimal_places=6, help_text='Коэффициент конверсии на момент заказа', max_digits=15, null=True, verbose_name='Коэффициент конверсии (snapshot)'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='orderitem',
|
||
name='quantity_in_base_units',
|
||
field=models.DecimalField(blank=True, decimal_places=6, help_text='Количество в единицах хранения товара (для списания со склада)', max_digits=10, null=True, verbose_name='Количество в базовых единицах'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='orderitem',
|
||
name='sales_unit',
|
||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='order_items', to='products.productsalesunit', verbose_name='Единица продажи'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='orderitem',
|
||
name='unit_name_snapshot',
|
||
field=models.CharField(blank=True, default='', help_text='Название единицы продажи на момент заказа', max_length=100, verbose_name='Название единицы (snapshot)'),
|
||
),
|
||
]
|