# Generated by Django 2.1.7 on 2019-10-24 16:02

import company.models
from django.conf import settings
import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='User',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('password', models.CharField(max_length=128, verbose_name='password')),
                ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
                ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
                ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
                ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
                ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
                ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
                ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
                ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
                ('external_id', models.IntegerField(blank=True, null=True, unique=True, verbose_name='外部ID')),
                ('external_code', models.CharField(blank=True, max_length=30, null=True, verbose_name='外部编码')),
                ('phone', models.CharField(blank=True, max_length=20, null=True, verbose_name='电话')),
                ('wx_account', models.CharField(blank=True, max_length=30, null=True, verbose_name='微信号')),
                ('wx_pub_account', models.CharField(blank=True, max_length=30, null=True, verbose_name='微信公众号')),
                ('legacy_id', models.IntegerField(blank=True, null=True, verbose_name='SqlSrvID')),
                ('is_active', models.BooleanField(default=True, verbose_name='是否已激活')),
                ('is_delete', models.BooleanField(default=False, verbose_name='是否已删除')),
                ('tm', models.DateTimeField(auto_now_add=True, verbose_name='时间')),
            ],
            options={
                'verbose_name': '用户帐号',
                'verbose_name_plural': '用户帐号',
            },
            managers=[
                ('objects', django.contrib.auth.models.UserManager()),
            ],
        ),
        migrations.CreateModel(
            name='AuthorizedProducts',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('dt_from', models.DateField(blank=True, null=True, verbose_name='授权开始日期')),
                ('dt_to', models.DateField(blank=True, null=True, verbose_name='授权结束日期')),
                ('tm', models.DateField(auto_now_add=True, verbose_name='授权时间')),
            ],
            options={
                'verbose_name': '产品授权',
                'verbose_name_plural': '产品授权',
            },
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True, verbose_name='分类名称')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明')),
                ('tm', models.DateTimeField(auto_now_add=True, verbose_name='生成时间')),
            ],
            options={
                'verbose_name': '公司类别',
                'verbose_name_plural': '公司类别',
            },
        ),
        migrations.CreateModel(
            name='CategoryProp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, verbose_name='属性名称')),
                ('desc_cn', models.CharField(max_length=50, verbose_name='中文属性名')),
                ('desc_en', models.CharField(blank=True, max_length=50, null=True, verbose_name='英文属性名')),
                ('unit', models.CharField(blank=True, max_length=20, null=True, verbose_name='单位')),
                ('type', models.CharField(blank=True, choices=[('c', '字符'), ('n', '数字')], max_length=10, null=True, verbose_name='值类型')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明')),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='company.Category', verbose_name='公司类别')),
            ],
            options={
                'verbose_name': '属性类别',
                'verbose_name_plural': '属性类别',
            },
        ),
        migrations.CreateModel(
            name='Company',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(db_index=True, max_length=50, verbose_name='公司名称')),
                ('legacy_id', models.IntegerField(blank=True, null=True, verbose_name='SqlSrvID')),
                ('lar', models.CharField(blank=True, max_length=20, null=True, verbose_name='法人代表')),
                ('ctyid', models.IntegerField(blank=True, null=True, verbose_name='CTID')),
                ('external_code', models.CharField(blank=True, help_text='企业自有编码，如SAP编码', max_length=30, null=True, verbose_name='外部编码')),
                ('log_code', models.CharField(blank=True, help_text='企业原有物流码', max_length=30, null=True, verbose_name='物流编码')),
                ('external_id', models.IntegerField(blank=True, null=True, unique=True, verbose_name='外部ID')),
                ('is_active', models.BooleanField(default=True, verbose_name='是否已激活')),
                ('is_delete', models.BooleanField(default=False, verbose_name='是否已删除')),
                ('is_legacy', models.BooleanField(default=True, verbose_name='使用SqlSrvID')),
                ('is_microboss', models.BooleanField(default=False, verbose_name='是否是微商')),
                ('has_logcode', models.BooleanField(default=False, verbose_name='是否已有物流码')),
                ('has_external_code', models.BooleanField(default=False, verbose_name='使用外部ID')),
                ('has_plant', models.BooleanField(default=False, verbose_name='分工厂/厂区')),
                ('has_workshop', models.BooleanField(default=False, verbose_name='分车间')),
                ('tm', models.DateTimeField(auto_now_add=True, verbose_name='时间')),
                ('tm_register', models.DateTimeField(blank=True, null=True, verbose_name='注册时间')),
                ('inv_mgt', models.BooleanField(blank=True, default=False, null=True, verbose_name='库存管理')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明')),
                ('idnumber', models.CharField(blank=True, max_length=30, null=True, verbose_name='身份证号码')),
                ('address', models.CharField(blank=True, max_length=100, null=True, verbose_name='详细地址')),
                ('adm_id', models.IntegerField(blank=True, null=True, verbose_name='GIS')),
                ('cell_phone', models.CharField(blank=True, max_length=20, null=True, verbose_name='手机号码')),
                ('wx_pub_account', models.CharField(blank=True, max_length=30, null=True, verbose_name='微信公众号')),
                ('wx_app_id', models.CharField(blank=True, max_length=30, null=True, verbose_name='微信AppID')),
                ('wx_open_id', models.CharField(blank=True, max_length=50, null=True, verbose_name='微信OpenID')),
                ('wx_user_number', models.CharField(blank=True, max_length=50, null=True, verbose_name='微信号')),
                ('img_logo', models.ImageField(blank=True, null=True, upload_to=company.models.company_upload_logo, verbose_name='公司LOGO')),
                ('img_banner', models.ImageField(blank=True, null=True, upload_to=company.models.company_upload_banner, verbose_name='网页banner')),
                ('img_bg', models.ImageField(blank=True, null=True, upload_to=company.models.company_upload_bg, verbose_name='网页背景')),
                ('img_id', models.ImageField(blank=True, null=True, upload_to=company.models.company_upload_id, verbose_name='身份证')),
                ('ty_id', models.IntegerField(blank=True, null=True, unique=True, verbose_name='酒鬼透云ID')),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='company.Category', verbose_name='公司类别')),
            ],
            options={
                'verbose_name': '公司名称',
                'verbose_name_plural': '公司名称',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Level',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True, verbose_name='层级名称')),
                ('sn', models.SmallIntegerField(blank=True, null=True, verbose_name='层级序号')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明')),
                ('category', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='company.Category', verbose_name='公司类别')),
            ],
            options={
                'verbose_name': '营销层级',
                'verbose_name_plural': '营销层级',
                'ordering': ['sn'],
            },
        ),
        migrations.CreateModel(
            name='PrdLine',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('legacy_id', models.IntegerField(blank=True, null=True, verbose_name='SqlSrvID')),
                ('external_code', models.CharField(blank=True, max_length=30, null=True, verbose_name='外部编码')),
                ('name', models.CharField(max_length=20, 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='line_company', to='company.Company', verbose_name='公司名称')),
            ],
            options={
                'verbose_name': '生产线',
                'verbose_name_plural': '生产线',
            },
        ),
        migrations.CreateModel(
            name='PrdPlant',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('legacy_id', models.IntegerField(blank=True, null=True, verbose_name='SqlSrvID')),
                ('external_code', models.CharField(blank=True, max_length=30, null=True, verbose_name='外部编码')),
                ('name', models.CharField(max_length=50, verbose_name='工厂/厂区名称')),
                ('address', models.CharField(blank=True, max_length=100, 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='plant_company', to='company.Company', verbose_name='公司名称')),
            ],
            options={
                'verbose_name': '工厂/厂区',
                'verbose_name_plural': '工厂/厂区',
            },
        ),
        migrations.CreateModel(
            name='PrdQc',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('legacy_id', models.IntegerField(blank=True, null=True, verbose_name='SqlSrvID')),
                ('external_code', models.CharField(blank=True, max_length=30, null=True, verbose_name='外部编码')),
                ('name', models.CharField(max_length=50, verbose_name='质检员')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='qc_company', to='company.Company', verbose_name='公司名称')),
                ('prd_plant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='qc_plant', to='company.PrdPlant', verbose_name='工厂/厂区')),
            ],
            options={
                'verbose_name': '质检员',
                'verbose_name_plural': '质检员',
            },
        ),
        migrations.CreateModel(
            name='PrdTeam',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(choices=[('production', '生产班组'), ('inspection', '检验班组')], default='生产班组', max_length=20, verbose_name='班组类别')),
                ('name', models.CharField(max_length=50, verbose_name='班组名称')),
                ('legacy_id', models.IntegerField(blank=True, null=True, verbose_name='SqlSrvID')),
                ('external_code', models.CharField(blank=True, max_length=30, null=True, verbose_name='外部编码')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明 ')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='team_company', to='company.Company', verbose_name='公司名称')),
                ('prd_line', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='team_line', to='company.PrdLine', verbose_name='生产线')),
                ('prd_plant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='team_plant', to='company.PrdPlant', verbose_name='工厂/厂区')),
            ],
            options={
                'verbose_name': '生产班组',
                'verbose_name_plural': '生产班组',
            },
        ),
        migrations.CreateModel(
            name='PrdWorkshop',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('adm_id', models.IntegerField(blank=True, null=True, verbose_name='GIS')),
                ('province', models.CharField(blank=True, max_length=20, null=True, verbose_name='省份')),
                ('city', models.CharField(blank=True, max_length=20, null=True, verbose_name='城市')),
                ('address', models.CharField(blank=True, max_length=100, null=True, verbose_name='地址')),
                ('legacy_id', models.IntegerField(blank=True, null=True, verbose_name='SqlSrvID')),
                ('external_code', models.CharField(blank=True, max_length=30, null=True, verbose_name='外部编码')),
                ('name', models.CharField(max_length=50, verbose_name='车间名称')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明 ')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workshop_company', to='company.Company', verbose_name='公司名称')),
                ('prd_plant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='workshop_plant', to='company.PrdPlant', verbose_name='工厂厂区')),
            ],
            options={
                'verbose_name': '生产车间',
                'verbose_name_plural': '生产车间',
            },
        ),
        migrations.CreateModel(
            name='SalesDivision',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(blank=True, max_length=10, null=True, verbose_name='战区编码')),
                ('name', models.CharField(max_length=50, verbose_name='战区名称')),
                ('is_delete', models.BooleanField(default=False, verbose_name='是否已删除')),
                ('tm', models.DateTimeField(auto_now_add=True, verbose_name='时间')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='division_company', to='company.Company', verbose_name='公司名称')),
                ('manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='战区经理')),
            ],
            options={
                'verbose_name': '营销战区',
                'verbose_name_plural': '营销战区',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='SubSalDivision',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(blank=True, max_length=10, null=True, verbose_name='分区编码')),
                ('name', models.CharField(max_length=50, verbose_name='分区名称')),
                ('is_delete', models.BooleanField(default=False, verbose_name='是否已删除')),
                ('tm', models.DateTimeField(auto_now_add=True, verbose_name='时间')),
                ('remark', models.CharField(blank=True, max_length=100, null=True, verbose_name='备注说明')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sub_division_company', to='company.Company', verbose_name='公司名称')),
                ('division', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='company.SalesDivision', verbose_name='营销战区')),
                ('manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='分区经理')),
            ],
            options={
                'verbose_name': '营销分区',
                'verbose_name_plural': '营销分区',
                'ordering': ['name'],
            },
        ),
        migrations.AddField(
            model_name='prdteam',
            name='prd_workshop',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='team_shop', to='company.PrdWorkshop', verbose_name='生产车间'),
        ),
        migrations.AddField(
            model_name='prdqc',
            name='prd_workshop',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='qc_shop', to='company.PrdWorkshop', verbose_name='生产车间'),
        ),
        migrations.AddField(
            model_name='prdline',
            name='prd_plant',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='line_plant', to='company.PrdPlant', verbose_name='工厂/厂区'),
        ),
        migrations.AddField(
            model_name='prdline',
            name='prd_workshop',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='line_shop', to='company.PrdWorkshop', verbose_name='生产车间'),
        ),
        migrations.AddField(
            model_name='company',
            name='division',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='company_division', to='company.SalesDivision', verbose_name='营销大区'),
        ),
        migrations.AddField(
            model_name='company',
            name='hierarchy',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='company_hierarchy', to='company.Company', verbose_name='体系'),
        ),
        migrations.AddField(
            model_name='company',
            name='level',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='company.Level', verbose_name='层级'),
        ),
        migrations.AddField(
            model_name='company',
            name='parent',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='company.Company', verbose_name='父级'),
        ),
        migrations.AddField(
            model_name='company',
            name='sub_division',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='company_division', to='company.SubSalDivision', verbose_name='营销分区'),
        ),
        migrations.AddField(
            model_name='authorizedproducts',
            name='company',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='a_company', to='company.Company', verbose_name='经销商'),
        ),
    ]
