50 lines
2.6 KiB
Python
50 lines
2.6 KiB
Python
# Generated by Django 5.2.5 on 2025-08-19 08:54
|
|
|
|
import django.core.validators
|
|
import django.db.models.deletion
|
|
from decimal import Decimal
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('inventory', '0003_remove_supplier_rating'),
|
|
('manufacture', '0001_initial'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='BillOfMaterials',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('quantity', models.DecimalField(decimal_places=4, help_text='Quantity of component needed per unit of manufactured product', max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.0001'))])),
|
|
('unit', models.CharField(blank=True, help_text='Unit of measurement for the component (e.g., kg, pieces, meters)', max_length=20)),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
('component', models.ForeignKey(help_text='A component used in manufacturing', on_delete=django.db.models.deletion.CASCADE, related_name='bom_components', to='inventory.product')),
|
|
('manufactured_product', models.ForeignKey(help_text='The product that is manufactured using this BOM', on_delete=django.db.models.deletion.CASCADE, related_name='bom_manufactured', to='inventory.product')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Bill of Materials',
|
|
'verbose_name_plural': 'Bills of Materials',
|
|
'ordering': ['manufactured_product__name', 'component__name'],
|
|
'unique_together': {('manufactured_product', 'component')},
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='BillOfMaterialsTotal',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('total_cost', models.DecimalField(decimal_places=4, default=0, max_digits=12)),
|
|
('total_weight', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
|
|
('last_calculated', models.DateTimeField(auto_now=True)),
|
|
('bom', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='totals', to='manufacture.billofmaterials')),
|
|
],
|
|
options={
|
|
'verbose_name': 'BOM Total',
|
|
'verbose_name_plural': 'BOM Totals',
|
|
},
|
|
),
|
|
]
|