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.
41 lines
2.0 KiB
Python
41 lines
2.0 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 = [
|
||
('inventory', '0002_initial'),
|
||
('products', '0006_populate_unit_of_measure'),
|
||
]
|
||
|
||
operations = [
|
||
migrations.AddField(
|
||
model_name='reservation',
|
||
name='quantity_base',
|
||
field=models.DecimalField(blank=True, decimal_places=6, help_text='Количество в единицах хранения товара', max_digits=10, null=True, verbose_name='Количество в базовых единицах'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='reservation',
|
||
name='sales_unit',
|
||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reservations', to='products.productsalesunit', verbose_name='Единица продажи'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='sale',
|
||
name='quantity_base',
|
||
field=models.DecimalField(blank=True, decimal_places=6, help_text='Количество в единицах хранения товара (для списания со склада)', max_digits=10, null=True, verbose_name='Количество в базовых единицах'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='sale',
|
||
name='sales_unit',
|
||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sales', to='products.productsalesunit', verbose_name='Единица продажи'),
|
||
),
|
||
migrations.AddField(
|
||
model_name='sale',
|
||
name='unit_name_snapshot',
|
||
field=models.CharField(blank=True, default='', help_text='Название единицы продажи на момент продажи', max_length=100, verbose_name='Название единицы (snapshot)'),
|
||
),
|
||
]
|