37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from django.db import migrations, models
|
|
|
|
|
|
def migrate_scope_forward(apps, schema_editor):
|
|
Process = apps.get_model('mtm', 'Process')
|
|
Process.objects.filter(into_wm_mgroup=True).update(into_wm_scope=10)
|
|
|
|
|
|
def migrate_scope_backward(apps, schema_editor):
|
|
Process = apps.get_model('mtm', 'Process')
|
|
Process.objects.filter(into_wm_scope=10).update(into_wm_mgroup=True)
|
|
Process.objects.exclude(into_wm_scope=10).update(into_wm_mgroup=False)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('mtm', '0067_material_test_mode_in'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='process',
|
|
name='into_wm_scope',
|
|
field=models.PositiveSmallIntegerField(
|
|
choices=[(10, '工段'), (20, '部门'), (30, '全局')],
|
|
default=20,
|
|
verbose_name='产出库存归属',
|
|
),
|
|
),
|
|
migrations.RunPython(migrate_scope_forward, migrate_scope_backward),
|
|
migrations.RemoveField(
|
|
model_name='process',
|
|
name='into_wm_mgroup',
|
|
),
|
|
]
|