feat: ftestwork增加是否更新库存字段
This commit is contained in:
parent
40b012b962
commit
fc2195eba1
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2024-09-02 07:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('qm', '0022_ftestwork_count_sampling_ok'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='ftestwork',
|
||||
name='need_update_wm',
|
||||
field=models.BooleanField(default=True, verbose_name='是否更新车间库存'),
|
||||
),
|
||||
]
|
|
@ -122,6 +122,7 @@ class FtestWork(CommonBDModel):
|
|||
count_sampling_ok = models.IntegerField('抽检合格数量', default=0)
|
||||
count_ok = models.IntegerField('合格数量', default=0)
|
||||
count_notok = models.IntegerField('不合格数量', default=0)
|
||||
need_update_wm = models.BooleanField('是否更新车间库存', default=True)
|
||||
count_notok_json = models.JSONField('不合格项数量统计', default=dict, null=False, blank=True)
|
||||
test_user = models.ForeignKey(
|
||||
User, verbose_name='操作人', on_delete=models.CASCADE, related_name='ftestwork_test_user', null=True, blank=True)
|
||||
|
|
|
@ -63,7 +63,7 @@ class QuaStatUpdateSerializer(CustomModelSerializer):
|
|||
class FtestWorkCreateUpdateSerializer(CustomModelSerializer):
|
||||
class Meta:
|
||||
model = FtestWork
|
||||
fields = ['id', 'wm', 'mb', 'type', 'type2', 'test_date', 'count', 'count_sampling', 'count_ok', 'count_notok', 'count_notok_json', 'test_user']
|
||||
fields = ['id', 'wm', 'mb', 'type', 'type2', 'test_date', 'count', 'count_sampling', 'count_ok', 'count_notok', 'count_notok_json', 'test_user', 'need_update_wm']
|
||||
extra_kwargs = {'test_user': {'required': True}, 'type': {'required': True}}
|
||||
|
||||
def validate(self, attrs):
|
||||
|
|
|
@ -7,6 +7,7 @@ from django.utils import timezone
|
|||
|
||||
def ftestwork_submit(ins:FtestWork, user: User):
|
||||
wm:WMaterial = ins.wm
|
||||
if ins.need_update_wm:
|
||||
if wm.state == WMaterial.WM_TEST:
|
||||
# 更新对应的车间库存
|
||||
wm.count = wm.count - ins.count
|
||||
|
|
Loading…
Reference in New Issue