From b0ea55121b0aa5d2c1b12b150062da106fbe3237 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 17 Mar 2022 08:31:38 +0800 Subject: [PATCH] =?UTF-8?q?wproductflow=20child=E5=AD=97=E6=AE=B5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0055_alter_wproductflow_child.py | 19 +++++++++++++++++++ hb_server/apps/wpm/models.py | 4 ++-- hb_server/apps/wpm/services.py | 6 ++---- 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 hb_server/apps/wpm/migrations/0055_alter_wproductflow_child.py diff --git a/hb_server/apps/wpm/migrations/0055_alter_wproductflow_child.py b/hb_server/apps/wpm/migrations/0055_alter_wproductflow_child.py new file mode 100644 index 0000000..9585114 --- /dev/null +++ b/hb_server/apps/wpm/migrations/0055_alter_wproductflow_child.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.9 on 2022-03-17 00:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wpm', '0054_auto_20220315_1500'), + ] + + operations = [ + migrations.AlterField( + model_name='wproductflow', + name='child', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='wpf_child', to='wpm.wproduct'), + ), + ] diff --git a/hb_server/apps/wpm/models.py b/hb_server/apps/wpm/models.py index b408f18..085a20d 100644 --- a/hb_server/apps/wpm/models.py +++ b/hb_server/apps/wpm/models.py @@ -100,7 +100,7 @@ class WProduct(CommonAModel): act_state = models.IntegerField( '进行状态', default=0, choices=act_state_choices) is_hidden = models.BooleanField('是否隐藏', default=False) - child = models.ForeignKey('self', blank=True, null=True, + child = models.ForeignKey('wpm.wproduct', blank=True, null=True, on_delete=models.CASCADE, related_name='wp_child') remark = models.CharField('备注', max_length=200, null=True, blank=True) subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE, @@ -176,7 +176,7 @@ class WproductFlow(CommonAModel): act_state = models.IntegerField( '进行状态', default=0, choices=WProduct.act_state_choices) is_hidden = models.BooleanField('是否隐藏', default=False) - child = models.ForeignKey('self', blank=True, null=True, + child = models.ForeignKey('wpm.wproduct', blank=True, null=True, on_delete=models.CASCADE, related_name='wpf_child') remark = models.CharField('备注', max_length=200, null=True, blank=True) subproduction_plan = models.ForeignKey( diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index 0058e5d..4440122 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -162,9 +162,8 @@ class WpmService(object): ins = WproductFlow() ins.wproduct = instance for f in WproductFlow._meta.fields: - if f.name not in ['id', 'wproduct', 'is_lastlog', 'child']: + if f.name not in ['id', 'wproduct', 'is_lastlog']: setattr(ins, f.name, getattr(instance, f.name, None)) - ins.child = instance.child ins.change_str = change_str ins.save() @@ -179,9 +178,8 @@ class WpmService(object): ins = WproductFlow() ins.wproduct = i for f in WproductFlow._meta.fields: - if f.name not in ['id', 'wproduct', 'is_lastlog', 'child']: + if f.name not in ['id', 'wproduct', 'is_lastlog']: setattr(ins, f.name, getattr(i, f.name, None)) - ins.child = i.child ins.change_str = change_str wfw.append(ins) WproductFlow.objects.bulk_create(wfw)