feat: labelmat和wpr都加上返修Enum

This commit is contained in:
caoqianming 2025-02-24 10:26:00 +08:00
parent 0c5cc55b54
commit 553fbcc826
6 changed files with 44 additions and 5 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2025-02-24 02:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cm', '0002_lablemat_defect'),
]
operations = [
migrations.AlterField(
model_name='lablemat',
name='state',
field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (34, '返修完成'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'),
),
]

View File

@ -2,10 +2,11 @@ from django.db import models
from apps.utils.models import BaseModel
from apps.mtm.models import Material
from apps.pum.models import Supplier
from apps.wpm.models import WmStateOption
# Create your models here.
class LableMat(BaseModel):
state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废')))
state = models.PositiveSmallIntegerField('状态', default=10, choices=WmStateOption.choices)
material = models.ForeignKey(Material, on_delete=models.CASCADE)
batch = models.CharField('批次号', max_length=100)
supplier = models.ForeignKey(Supplier, verbose_name='外协供应商', on_delete=models.SET_NULL, null=True, blank=True)

View File

@ -18,6 +18,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='wmaterial',
name='state',
field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (32, '返修完成'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'),
field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (34, '返修完成'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'),
),
]

View File

@ -96,6 +96,7 @@ class WmStateOption(models.IntegerChoices):
OK = 10, _("合格")
NOTOK = 20, _("不合格")
REPAIR = 30, _("返修")
REPAIRED = 34, _("返修完成")
TEST = 40, _("检验")
SCRAP = 50, _("报废")
@ -108,7 +109,7 @@ class WMaterial(CommonBDModel):
WM_REPAIR = 30
WM_TEST = 40
WM_SCRAP = 50
state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (32, '返修完成'), (40, '检验'), (50, '报废')))
state = models.PositiveSmallIntegerField('状态', default=10, choices=WmStateOption.choices)
material = models.ForeignKey(
Material, verbose_name='物料', on_delete=models.CASCADE, related_name='wm_m')
supplier = models.ForeignKey(Supplier, verbose_name='外协供应商', on_delete=models.SET_NULL, null=True, blank=True)
@ -144,7 +145,7 @@ class WMaterial(CommonBDModel):
material_out=mtask.material_in
).values_list('batch', flat=True)
),
state__in=[WMaterial.WM_OK]
state__in=[WMaterial.WM_OK, WMaterial.WM_REPAIR]
)
class Fmlog(CommonADModel):

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2025-02-24 02:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wpmw', '0002_wpr_oinfo'),
]
operations = [
migrations.AlterField(
model_name='wpr',
name='state',
field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (34, '返修完成'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'),
),
]

View File

@ -4,6 +4,7 @@ from apps.qm.models import FtestDefect, FtestItem
from apps.utils.models import BaseModel
from apps.mtm.models import Material
from rest_framework.exceptions import ParseError
from apps.wpm.models import WmStateOption
# Create your models here.
class Wpr(BaseModel):
@ -12,7 +13,7 @@ class Wpr(BaseModel):
"""
number = models.CharField("编号", max_length=50, unique=True, null=True, blank=True)
state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废')))
state = models.PositiveSmallIntegerField('状态', default=10, choices=WmStateOption.choices)
material = models.ForeignKey(Material, verbose_name="当前物料形态", on_delete=models.CASCADE)
defects = models.ManyToManyField("qm.defect", through="wpmw.wprdefect", verbose_name="缺陷项")