feat: 支持退料交接

This commit is contained in:
caoqianming 2025-03-31 14:17:20 +08:00
parent 88da422f54
commit 3c0e416735
3 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2025-03-31 06:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wpm', '0105_handover_new_wm'),
]
operations = [
migrations.AlterField(
model_name='handover',
name='type',
field=models.PositiveSmallIntegerField(choices=[(10, '正常交接'), (20, '返修交接'), (30, '检验交接'), (40, '报废交接'), (50, '改版交接'), (60, '退料交接')], default=10, verbose_name='交接类型'),
),
]

View File

@ -481,6 +481,8 @@ class Handover(CommonADModel):
H_TEST = 30
H_SCRAP = 40
H_CHANGE = 50
H_BACK = 60
H_MERGE = 30
H_DIV = 20
new_batch = models.TextField('新批次号', null=True, blank=True)
@ -489,7 +491,7 @@ class Handover(CommonADModel):
[(H_NORMAL, '正常'), (H_DIV, '分批'), (H_MERGE, '合批')])
type = models.PositiveSmallIntegerField('交接类型', choices=[
(H_NORMAL, '正常交接'), (H_REPAIR, '返修交接'),
(H_TEST, '检验交接'), (H_SCRAP, '报废交接'), (H_CHANGE, '改版交接')], default=H_NORMAL)
(H_TEST, '检验交接'), (H_SCRAP, '报废交接'), (H_CHANGE, '改版交接'), (H_BACK, '退料交接')], default=H_NORMAL)
send_date = models.DateField('送料日期')
send_user = models.ForeignKey(
User, verbose_name='交送人', on_delete=models.CASCADE, related_name='handover_send_user')

View File

@ -842,6 +842,24 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
)
else:
raise ParseError("改版交接必须指定接收工段")
elif handover.type == Handover.H_BACK:
if mtype == Handover.H_MERGE and handover.new_wm:
wm_to = handover.new_wm
else:
wm_to, _ = WMaterial.objects.get_or_create(
batch=batch,
material=material,
mgroup=recive_mgroup,
belong_dept=recive_dept,
state=wm_from.state,
notok_sign=wm_from.notok_sign,
defect=wm_from.defect,
defaults={
"batch_ofrom": wm_from.batch_ofrom,
"material_ofrom": wm_from.material_ofrom,
"create_by": user
}
)
else:
raise ParseError("不支持该交接类型")