feat: handoverbw的处理2
This commit is contained in:
parent
26c7652095
commit
49d1b95968
|
@ -645,6 +645,7 @@ class Handoverbwserializer(CustomModelSerializer):
|
|||
model = Handoverbw
|
||||
fields = '__all__'
|
||||
read_only_fields = EXCLUDE_FIELDS_BASE + ["handoverb"]
|
||||
extra_kwargs = {'wpr': {'required': True}}
|
||||
|
||||
class HandoverbSerializer(CustomModelSerializer):
|
||||
batch = serializers.CharField(source='wm.batch', read_only=True)
|
||||
|
@ -776,7 +777,8 @@ class HandoverSerializer(CustomModelSerializer):
|
|||
if count == wm.count:
|
||||
Handoverbw.objects.filter(handoverb=hb).delete()
|
||||
for item in Wpr.get_qs_by_wm(wm):
|
||||
Handoverbw.objects.get_or_create(wpr=item, handoverb=handoverb)
|
||||
Handoverbw.objects.get_or_create(wpr=item, handoverb=handoverb,
|
||||
defaults={"number": item.number})
|
||||
elif handoverbw:
|
||||
raise ParseError("暂不支持")
|
||||
else:
|
||||
|
|
|
@ -11,7 +11,7 @@ from apps.system.models import User
|
|||
from apps.pm.models import Mtask
|
||||
from apps.mtm.models import Mgroup, Shift, Material, Route, RoutePack, Team, Srule
|
||||
|
||||
from .models import SfLog, WMaterial, Mlog, Mlogb, Mlogbw, Handover, Handoverb
|
||||
from .models import SfLog, WMaterial, Mlog, Mlogb, Mlogbw, Handover, Handoverb, Handoverbw
|
||||
from apps.mtm.services import cal_material_count
|
||||
from apps.wf.models import Ticket
|
||||
from apps.utils.thread import MyThread
|
||||
|
@ -575,23 +575,23 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
now = timezone.now()
|
||||
handoverb_qs = Handoverb.objects.filter(handover=handover)
|
||||
need_add = True
|
||||
material = handover.material
|
||||
material:Material = handover.material
|
||||
if '混料' in material.name: # hard code
|
||||
need_add = False
|
||||
if handoverb_qs.exists():
|
||||
handoverb_list = [(item.wm, item.count) for item in handoverb_qs]
|
||||
handoverb_list = [(item.wm, item.count, item) for item in handoverb_qs]
|
||||
else:
|
||||
handoverb_list = [(handover.wm, handover.count)]
|
||||
handoverb_list = [(handover.wm, handover.count, handover)]
|
||||
|
||||
recive_mgroup = handover.recive_mgroup
|
||||
recive_dept = handover.recive_dept
|
||||
batches = []
|
||||
for item in handoverb_list:
|
||||
wm_from, xcount = item
|
||||
wm_from, xcount, handover_or_b = item
|
||||
batch = wm_from.batch
|
||||
|
||||
if wm_from is None:
|
||||
raise ParseError('找不到车间库存')
|
||||
|
||||
batches.append(batch)
|
||||
|
||||
count_x = wm_from.count - xcount
|
||||
|
@ -600,6 +600,7 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
else:
|
||||
wm_from.count = count_x
|
||||
wm_from.save()
|
||||
|
||||
if need_add:
|
||||
# 开始变动
|
||||
if handover.type == Handover.H_NORMAL:
|
||||
|
@ -670,6 +671,13 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
wm_to.count = wm_to.count + xcount
|
||||
wm_to.count_eweight = handover.count_eweight # 这行代码有隐患
|
||||
wm_to.save()
|
||||
if material.tracking == Material.MA_TRACKING_SINGLE:
|
||||
handoverbws = Handoverbw.objects.filter(handoverb=handover_or_b)
|
||||
if handoverbws.count() != xcount:
|
||||
raise ParseError("交接与明细数量不一致,操作失败")
|
||||
for item in handoverbws:
|
||||
Wpr.change_or_new(wpr=item.wpr, wm=wm_to)
|
||||
|
||||
handover.submit_user = user
|
||||
handover.submit_time = now
|
||||
handover.save()
|
||||
|
|
Loading…
Reference in New Issue