feat: handover submit支持合并为单个新批次

This commit is contained in:
caoqianming 2025-01-13 17:26:41 +08:00
parent 77faee5d1a
commit f68d498dd3
3 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2025-01-13 09:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wpm', '0084_alter_mlogbw_ftest'),
]
operations = [
migrations.AddField(
model_name='handover',
name='new_batch',
field=models.TextField(blank=True, null=True, verbose_name='新批次号'),
),
]

View File

@ -368,6 +368,7 @@ class Handover(CommonADModel):
H_REPAIR = 20
H_TEST = 30
H_SCRAP = 40
new_batch = models.TextField('新批次号', null=True, blank=True)
type = models.PositiveSmallIntegerField('交接类型', choices=[(H_NORMAL, '正常交接'), (H_REPAIR, '返修交接'), (H_TEST, '检验交接'), (H_SCRAP, '报废交接')], default=H_NORMAL)
send_date = models.DateField('送料日期')
send_user = models.ForeignKey(

View File

@ -641,13 +641,20 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
recive_mgroup = handover.recive_mgroup
recive_dept = handover.recive_dept
batches = []
new_batch = handover.new_batch
if new_batch:
batches = [new_batch]
for item in handoverb_list:
wm_from, xcount, handover_or_b = item
batch = wm_from.batch
batches.append(batch)
# 合并为新批
if new_batch:
batch = new_batch
if wm_from is None:
raise ParseError('找不到车间库存')
batches.append(batch)
count_x = wm_from.count - xcount
if count_x < 0:
@ -731,7 +738,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
if handoverbws.count() != xcount:
raise ParseError("交接与明细数量不一致,操作失败")
for item in handoverbws:
Wpr.change_or_new(wpr=item.wpr, wm=wm_to)
wpr:Wpr = item.wpr
Wpr.change_or_new(wpr=wpr, wm=wm_to, old_wm=wpr.wm, old_mb=wpr.mb)
handover.submit_user = user
handover.submit_time = now