# Generated by Django 3.1.4 on 2021-05-28 16:39

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('company', '0209_cgroup_tm_edit'),
        ('inventory', '0106_auto_20210422_1510'),
        ('product', '0015_auto_20210428_1433'),
    ]

    operations = [
        migrations.CreateModel(
            name='Batch',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(blank=True, db_index=True, max_length=20, null=True, verbose_name='单据号码')),
                ('dt', models.DateField(auto_now_add=True, db_index=True, verbose_name='日期')),
                ('tm', models.DateTimeField(auto_now_add=True, verbose_name='生成时间')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mesbatch_company', to='company.company', verbose_name='企业名称')),
            ],
            options={
                'verbose_name': 'MES进出存批处理',
                'verbose_name_plural': 'MES进出存批处理',
            },
        ),
        migrations.CreateModel(
            name='BOM',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, max_length=50, null=True, verbose_name='物料单名称')),
                ('code', models.CharField(blank=True, max_length=20, null=True, verbose_name='物料单编码')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bom_company', to='company.company', verbose_name='所属企业')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bom_product', to='product.product', verbose_name='产成品')),
            ],
            options={
                'verbose_name': '物料单',
                'verbose_name_plural': '物料单',
                'unique_together': {('company', 'product')},
            },
        ),
        migrations.CreateModel(
            name='Materials',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, verbose_name='原材料名称')),
                ('code', models.CharField(blank=True, max_length=20, null=True, verbose_name='材料编码')),
                ('units', models.JSONField(default=list, verbose_name='计量单位')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='materials_company', to='company.company', verbose_name='所属企业')),
            ],
            options={
                'verbose_name': '原材料',
                'verbose_name_plural': '原材料',
                'unique_together': {('company', 'name')},
            },
        ),
        migrations.CreateModel(
            name='Measure',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=20, unique=True, verbose_name='类别名称')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
            ],
            options={
                'verbose_name': '计量类别',
                'verbose_name_plural': '计量类别',
            },
        ),
        migrations.CreateModel(
            name='Packaging',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, verbose_name='包材名称')),
                ('code', models.CharField(blank=True, max_length=20, null=True, verbose_name='包材编码')),
                ('units', models.JSONField(default=list, verbose_name='计量单位')),
                ('specification', models.CharField(blank=True, max_length=50, null=True, verbose_name='规格')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='packing_company', to='company.company', verbose_name='所属企业')),
            ],
            options={
                'verbose_name': '包装材料',
                'verbose_name_plural': '包装材料',
                'unique_together': {('company', 'name')},
            },
        ),
        migrations.CreateModel(
            name='SemiFinishedGoods',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, verbose_name='半成品名称')),
                ('code', models.CharField(blank=True, max_length=20, null=True, verbose_name='半成品编码')),
                ('units', models.JSONField(default=list, verbose_name='计算单位')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='semifinishedgoods_company', to='company.company', verbose_name='所属企业')),
            ],
            options={
                'verbose_name': '半成品',
                'verbose_name_plural': '半成品',
                'unique_together': {('company', 'name')},
            },
        ),
        migrations.CreateModel(
            name='Unit',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=20, unique=True, verbose_name='单位名称')),
                ('is_basis', models.BooleanField(default=False, verbose_name='是否为基准单位')),
                ('ratio', models.DecimalField(decimal_places=6, default=1, max_digits=13, verbose_name='与最基准单位换算比')),
                ('abbreviation', models.CharField(blank=True, max_length=20, null=True, verbose_name='单位缩写')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('measure', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='unit_measure', to='mes.measure', verbose_name='计量类别')),
            ],
            options={
                'verbose_name': '计量单位',
                'verbose_name_plural': '计量单位',
                'unique_together': {('measure', 'is_basis')},
            },
        ),
        migrations.CreateModel(
            name='Storehouse',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, max_length=50, null=True, verbose_name='名称')),
                ('code', models.CharField(blank=True, max_length=20, null=True, verbose_name='编码')),
                ('loccation', models.CharField(blank=True, max_length=50, null=True, verbose_name='仓库位置')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messtore_company', to='company.company', verbose_name='所属企业')),
            ],
            options={
                'verbose_name': '原材料仓库',
                'verbose_name_plural': '原材料仓库',
                'unique_together': {('company', 'name')},
            },
        ),
        migrations.CreateModel(
            name='StkDetails',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qc_name', models.CharField(blank=True, max_length=20, null=True, verbose_name='质检员姓名')),
                ('qc_tm', models.DateTimeField(blank=True, null=True, verbose_name='检验时间')),
                ('batch_no', models.CharField(blank=True, max_length=20, null=True, verbose_name='生产批次')),
                ('qty', models.IntegerField(verbose_name='数量')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('is_delete', models.BooleanField(blank=True, db_index=True, default=False, null=True, verbose_name='是否已删除')),
                ('batch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='mes.batch', verbose_name='MESbatch')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetails_company', to='company.company', verbose_name='公司名称')),
                ('materials', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetials_store_to', to='mes.materials', verbose_name='原材料')),
                ('packaging', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetials_store_to', to='mes.packaging', verbose_name='包装材料')),
                ('qc', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetails_user', to=settings.AUTH_USER_MODEL, verbose_name='质检员')),
                ('semifinishedgoods', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetials_store_to', to='mes.semifinishedgoods', verbose_name='半成品')),
                ('store_fr', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetials_store_fr', to='mes.storehouse', verbose_name='仓库名称')),
                ('store_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetials_store_to', to='mes.storehouse', verbose_name='转货目的仓库')),
                ('unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetails_unit', to='mes.unit', verbose_name='单位')),
                ('vtype', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messtkdetails_vtype', to='inventory.voucher', verbose_name='单据类别')),
            ],
            options={
                'verbose_name': 'MES进出存明细',
                'verbose_name_plural': 'MES进出存明细',
            },
        ),
        migrations.CreateModel(
            name='BOMsemifinishedgoods',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qty', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='数量')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('bom', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bomsemifinishedgoods_bom', to='mes.bom', verbose_name='物料单')),
                ('semifinishedgoods', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bomsemifinishedgoods_semi', to='mes.semifinishedgoods', verbose_name='半成品')),
                ('unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bomsemifinishedgoods_unit', to='mes.unit', verbose_name='单位')),
            ],
            options={
                'verbose_name': '半成品用料单',
                'verbose_name_plural': '半成品用料单',
            },
        ),
        migrations.CreateModel(
            name='BOMpackaging',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qty', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='数量')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('bom', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bompackaging_bom', to='mes.bom', verbose_name='物料单')),
                ('packaging', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bompackaging_pkg', to='mes.packaging', verbose_name='包装物')),
                ('unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bompackaging_unit', to='mes.unit', verbose_name='单位')),
            ],
            options={
                'verbose_name': '包材用料单',
                'verbose_name_plural': '包材用料单',
            },
        ),
        migrations.CreateModel(
            name='BOMmaterials',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qty', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='数量')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('bom', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bommaterials_bom', to='mes.bom', verbose_name='物料单')),
                ('materials', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bommaterials_mat', to='mes.materials', verbose_name='原材料')),
                ('unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bommaterials_unit', to='mes.unit', verbose_name='单位')),
            ],
            options={
                'verbose_name': '原材料用料单',
                'verbose_name_plural': '原材料用料单',
            },
        ),
        migrations.AddField(
            model_name='batch',
            name='store_fr',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='mesbatch_store_fr', to='mes.storehouse', verbose_name='仓库名称'),
        ),
        migrations.AddField(
            model_name='batch',
            name='store_to',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='mesbatch_store_to', to='mes.storehouse', verbose_name='转货目的仓库'),
        ),
        migrations.AddField(
            model_name='batch',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mesbatch_user', to=settings.AUTH_USER_MODEL, verbose_name='操作员'),
        ),
        migrations.AddField(
            model_name='batch',
            name='vtype',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mesbatch_vtype', to='inventory.voucher', verbose_name='单据类别ID'),
        ),
        migrations.CreateModel(
            name='CompanyUnit',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('category', models.SmallIntegerField(choices=[(1, '原材料'), (2, '半成品'), (3, '包装材料')], verbose_name='计量标的物')),
                ('is_standard', models.BooleanField(default=False, verbose_name='是否为企业标准计量单位')),
                ('remark', models.CharField(blank=True, max_length=50, null=True, verbose_name='备注说明')),
                ('dt', models.DateField(db_index=True, default=django.utils.timezone.now, verbose_name='日期')),
                ('tm', models.DateTimeField(default=django.utils.timezone.now, verbose_name='时间')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='companyunit_company', to='company.company', verbose_name='使用企业')),
                ('measure', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='companyunit_measure', to='mes.measure', verbose_name='计量类别')),
                ('unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='companyunit_unit', to='mes.unit', verbose_name='计量单位')),
            ],
            options={
                'verbose_name': '企业使用计量单位',
                'verbose_name_plural': '企业使用计量单位',
                'unique_together': {('company', 'measure', 'category', 'unit', 'is_standard')},
            },
        ),
    ]
