feat: mgroup增加自产和外协字段及相关逻辑校验

This commit is contained in:
caoqianming 2025-03-19 14:32:24 +08:00
parent 459fc3bbe8
commit a0084f7825
1 changed files with 6 additions and 1 deletions

View File

@ -529,7 +529,7 @@ class MlogSerializer(CustomModelSerializer):
def validate(self, attrs):
attrs['fill_way'] = Mlog.MLOG_2 # 只填第二级
attrs['mtype'] = Mlog.MTYPE_SELF # 默认为自生产
fmlog = attrs.get('fmlog', None)
fmlog:Fmlog = attrs.get('fmlog', None)
mtaskb = attrs.get('mtaskb', None)
if fmlog:
attrs['fill_way'] = Mlog.MLOG_12
@ -540,6 +540,7 @@ class MlogSerializer(CustomModelSerializer):
raise ParseError('未提供消耗的车间物料')
attrs['mgroup'] = fmlog.mgroup
attrs['mtask'] = fmlog.mtask
attrs['mtype'] = fmlog.mgroup.mtype
if attrs['mtask'].route:
attrs['route'] = attrs['mtask'].route
# if attrs['mtask'].mtaskb and mtaskb is None:
@ -552,6 +553,10 @@ class MlogSerializer(CustomModelSerializer):
raise ParseError('非合格品不可使用')
if wm_in.material != attrs['mtask'].material_in:
raise ParseError('消耗物料与任务不一致')
if attrs['mtype'] == Mlog.MTYPE_OUT:
supplier = attrs.get('supplier', None)
if not supplier:
raise ParseError('外协必须选择外协单位')
mtask = attrs.get('mtask', None)
count_notok = 0
for i in attrs: