feat: criado tabela no db (UnitOfMeasure, ProductComponent, StockMovementType, StockMovement) add UnitOfMeasure na tabela produtos

This commit is contained in:
2025-07-22 15:39:37 -03:00
parent b74736f391
commit a9289cb28d
9 changed files with 184 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
# Generated by Django 5.1.4 on 2025-07-22 18:36
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('products', '0003_product_cuisine'),
]
operations = [
migrations.CreateModel(
name='UnitOfMeasure',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(help_text="Ex: 'Unidade', 'Kg', 'Litro'", max_length=50, unique=True)),
('abbreviation', models.CharField(help_text="Ex: 'un', 'kg', 'L'", max_length=10, unique=True)),
],
),
migrations.CreateModel(
name='ProductComponent',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity_required', models.PositiveIntegerField(default=1, help_text='Quantidade deste componente necessária para o produto composto.')),
('component_product', models.ForeignKey(help_text='Um produto que é componente de outro produto.', on_delete=django.db.models.deletion.CASCADE, related_name='used_as_component_in', to='products.product')),
('composite_product', models.ForeignKey(help_text='O produto que é composto por outros produtos.', on_delete=django.db.models.deletion.CASCADE, related_name='composition_entries', to='products.product')),
],
options={
'unique_together': {('composite_product', 'component_product')},
},
),
migrations.AddField(
model_name='product',
name='components',
field=models.ManyToManyField(related_name='is_component_of', through='products.ProductComponent', to='products.product'),
),
migrations.AddField(
model_name='product',
name='unit_of_measure',
field=models.ForeignKey(blank=True, help_text='Unidade de medida para este produto.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='products.unitofmeasure'),
),
]