From f68d498dd3d43f729940965783c59432e4f44dae Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 13 Jan 2025 17:26:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20handover=20submit=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=B8=BA=E5=8D=95=E4=B8=AA=E6=96=B0=E6=89=B9?= =?UTF-8?q?=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/migrations/0085_handover_new_batch.py | 18 ++++++++++++++++++ apps/wpm/models.py | 1 + apps/wpm/services.py | 12 ++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 apps/wpm/migrations/0085_handover_new_batch.py diff --git a/apps/wpm/migrations/0085_handover_new_batch.py b/apps/wpm/migrations/0085_handover_new_batch.py new file mode 100644 index 00000000..9203f1ce --- /dev/null +++ b/apps/wpm/migrations/0085_handover_new_batch.py @@ -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='新批次号'), + ), + ] diff --git a/apps/wpm/models.py b/apps/wpm/models.py index f95d8123..90dd7bf2 100644 --- a/apps/wpm/models.py +++ b/apps/wpm/models.py @@ -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( diff --git a/apps/wpm/services.py b/apps/wpm/services.py index 600e24d0..208bcfb5 100644 --- a/apps/wpm/services.py +++ b/apps/wpm/services.py @@ -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