Files
dealerhub/backend/apps/purchase/migrations/0001_initial.py
T

140 lines
9.6 KiB
Python

# Generated by Django 5.2.12 on 2026-09-06 17:48
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('catalog', '0001_initial'),
('core', '0001_initial'),
('inventory', '0001_initial'),
('partner', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='PurchaseBill',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('is_deleted', models.BooleanField(default=False)),
('deleted_at', models.DateTimeField(blank=True, null=True)),
('ext_data', models.JSONField(blank=True, default=dict)),
('source_channel', models.CharField(blank=True, default='manual', max_length=32)),
('bill_no', models.CharField(max_length=64)),
('bill_date', models.DateField()),
('total_amount', models.DecimalField(decimal_places=4, default=0, max_digits=18)),
('state', models.CharField(choices=[('draft', '草稿'), ('confirmed', '已过账'), ('cancelled', '已取消')], default='draft', max_length=16)),
('remark', models.TextField(blank=True, default='')),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
('org', models.ForeignKey(blank=True, help_text='所属组织(多机构预留)', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.org')),
('supplier', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='purchase_bills', to='partner.supplier')),
('tenant', models.ForeignKey(help_text='所属租户', on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.tenant')),
('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
('warehouse', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='purchase_bills', to='inventory.warehouse')),
],
options={
'verbose_name_plural': '进货单',
'db_table': 'purchase_bill',
'ordering': ['-bill_date', '-id'],
},
),
migrations.CreateModel(
name='PurchaseBillLine',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('is_deleted', models.BooleanField(default=False)),
('deleted_at', models.DateTimeField(blank=True, null=True)),
('ext_data', models.JSONField(blank=True, default=dict)),
('source_channel', models.CharField(blank=True, default='manual', max_length=32)),
('quantity', models.DecimalField(decimal_places=4, max_digits=18)),
('unit_price', models.DecimalField(decimal_places=4, max_digits=18)),
('amount', models.DecimalField(decimal_places=4, default=0, max_digits=18)),
('bill', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='purchase.purchasebill')),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
('org', models.ForeignKey(blank=True, help_text='所属组织(多机构预留)', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.org')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='bill_lines', to='catalog.product')),
('tenant', models.ForeignKey(help_text='所属租户', on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.tenant')),
('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'purchase_bill_line',
'ordering': ['id'],
},
),
migrations.CreateModel(
name='PurchaseOrder',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('is_deleted', models.BooleanField(default=False)),
('deleted_at', models.DateTimeField(blank=True, null=True)),
('ext_data', models.JSONField(blank=True, default=dict)),
('source_channel', models.CharField(blank=True, default='manual', max_length=32)),
('bill_no', models.CharField(max_length=64)),
('bill_date', models.DateField()),
('expected_date', models.DateField(blank=True, null=True)),
('total_amount', models.DecimalField(decimal_places=4, default=0, max_digits=18)),
('state', models.CharField(choices=[('draft', '草稿'), ('confirmed', '已确认'), ('received', '已收货'), ('cancelled', '已取消')], default='draft', max_length=16)),
('remark', models.TextField(blank=True, default='')),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
('org', models.ForeignKey(blank=True, help_text='所属组织(多机构预留)', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.org')),
('supplier', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='purchase_orders', to='partner.supplier')),
('tenant', models.ForeignKey(help_text='所属租户', on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.tenant')),
('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
('warehouse', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='purchase_orders', to='inventory.warehouse')),
],
options={
'verbose_name_plural': '采购订单',
'db_table': 'purchase_order',
'ordering': ['-bill_date', '-id'],
'unique_together': {('tenant', 'bill_no')},
},
),
migrations.AddField(
model_name='purchasebill',
name='order',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='bills', to='purchase.purchaseorder'),
),
migrations.CreateModel(
name='PurchaseOrderLine',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('is_deleted', models.BooleanField(default=False)),
('deleted_at', models.DateTimeField(blank=True, null=True)),
('ext_data', models.JSONField(blank=True, default=dict)),
('source_channel', models.CharField(blank=True, default='manual', max_length=32)),
('quantity', models.DecimalField(decimal_places=4, max_digits=18)),
('unit_price', models.DecimalField(decimal_places=4, max_digits=18)),
('amount', models.DecimalField(decimal_places=4, default=0, max_digits=18)),
('received_qty', models.DecimalField(decimal_places=4, default=0, max_digits=18)),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='purchase.purchaseorder')),
('org', models.ForeignKey(blank=True, help_text='所属组织(多机构预留)', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.org')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='po_lines', to='catalog.product')),
('tenant', models.ForeignKey(help_text='所属租户', on_delete=django.db.models.deletion.PROTECT, related_name='+', to='core.tenant')),
('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'purchase_order_line',
'ordering': ['id'],
},
),
migrations.AlterUniqueTogether(
name='purchasebill',
unique_together={('tenant', 'bill_no')},
),
]