feat: 出入库添加工段逻辑

This commit is contained in:
zty 2024-07-30 13:24:21 +08:00
parent a587e570f0
commit ebf6f739ca
3 changed files with 25 additions and 4 deletions

View File

@ -0,0 +1,20 @@
# Generated by Django 3.2.12 on 2024-07-30 05:23
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('mtm', '0037_material_into_wm'),
('inm', '0018_mioitem_count_n_b'),
]
operations = [
migrations.AddField(
model_name='mio',
name='mgroup',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='mtm.mgroup', verbose_name='出入库工段'),
),
]

View File

@ -133,7 +133,7 @@ class MIOViewSet(CustomModelViewSet):
"""
queryset = MIO.objects.all()
select_related_fields = ['create_by', 'belong_dept', 'do_user',
'submit_user', 'supplier', 'order', 'customer', 'pu_order']
'submit_user', 'supplier', 'order', 'customer', 'pu_order', 'mgroup']
prefetch_related_fields = ['materials']
serializer_class = MIOListSerializer
retrieve_serializer_class = MIODetailSerializer

View File

@ -95,6 +95,7 @@ def do_out(mio: MIO):
生产领料到车间
"""
belong_dept = mio.belong_dept
mgroup = mio.mgroup
do_user = mio.do_user
mioitems = MIOItem.objects.filter(mio=mio)
for item in mioitems:
@ -116,15 +117,15 @@ def do_out(mio: MIO):
action_list = [[item.material, item.batch, item.count]]
for al in action_list:
xmaterial, xbatch, xcount = al
# 领到车间库存(工段)
# 领到车间库存(工段)
wm, new_create = WMaterial.objects.get_or_create(batch=xbatch, material=xmaterial,
belong_dept=belong_dept, mgroup=None, defaults={
belong_dept=belong_dept, mgroup=mgroup, defaults={
"batch": xbatch,
"material": xmaterial,
"count": xcount,
"create_by": do_user,
"belong_dept": belong_dept,
"mgroup": None,
"mgroup": mgroup,
})
if not new_create:
wm.count = wm.count + item.count