消耗与产出校验 主要是冷加工
This commit is contained in:
parent
bae9d3be2f
commit
b4e5937b28
|
@ -2,7 +2,7 @@ from django.db import models
|
|||
from django.db.models.base import Model
|
||||
import django.utils.timezone as timezone
|
||||
from django.db.models.query import QuerySet
|
||||
from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File
|
||||
from apps.system.models import CommonADModel, CommonAModel, CommonBModel, Organization, User, Dict, File
|
||||
from utils.model import SoftModel, BaseModel
|
||||
from simple_history.models import HistoricalRecords
|
||||
from apps.mtm.models import Material
|
||||
|
@ -50,7 +50,7 @@ class MaterialBatch(BaseModel):
|
|||
|
||||
|
||||
|
||||
class FIFO(CommonAModel):
|
||||
class FIFO(CommonADModel):
|
||||
"""
|
||||
出入库记录
|
||||
"""
|
||||
|
|
|
@ -115,7 +115,7 @@ class FIFOItemViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
|
|||
obj.fifo_item.save()
|
||||
return Response()
|
||||
|
||||
class FIFOViewSet(ListModelMixin, GenericViewSet):
|
||||
class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
|
||||
"""
|
||||
出入库记录
|
||||
"""
|
||||
|
@ -131,6 +131,12 @@ class FIFOViewSet(ListModelMixin, GenericViewSet):
|
|||
if self.action == 'list':
|
||||
return FIFOListSerializer
|
||||
return super().get_serializer_class()
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
if obj.is_submited:
|
||||
raise exceptions.APIException('该记录已审核,不可删除')
|
||||
return super().destroy(request, *args, **kwargs)
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=FIFOInPurSerializer)
|
||||
def in_pur(self, request, pk=None):
|
||||
|
@ -148,9 +154,9 @@ class FIFOViewSet(ListModelMixin, GenericViewSet):
|
|||
审核通过
|
||||
"""
|
||||
obj = self.get_object()
|
||||
# for i in FIFOItem.objects.filter(fifo=obj):
|
||||
# if not i.is_testok:
|
||||
# raise APIException('未检验通过, 不可审核')
|
||||
for i in FIFOItem.objects.filter(fifo=obj):
|
||||
if not i.is_testok:
|
||||
raise APIException('未检验通过, 不可审核')
|
||||
if obj.is_audited:
|
||||
raise APIException('该入库记录已审核通过')
|
||||
with transaction.atomic():
|
||||
|
|
|
@ -256,7 +256,13 @@ class OperationListSerializer(serializers.ModelSerializer):
|
|||
# return WProduct.objects.filter(ow_wproduct__operation=obj).values('id', 'number')
|
||||
|
||||
def get_count_work(self, obj):
|
||||
from django.db.models.aggregates import Sum
|
||||
count_work = 0
|
||||
if obj.step.type == Step.STEP_TYPE_NOM:
|
||||
count_work = OperationWproduct.objects.filter(operation=obj).count()
|
||||
else:
|
||||
count_work = OperationMaterial.objects.filter(operation=obj).annotate(count_work=Sum('count'))
|
||||
print(count_work)
|
||||
return count_work
|
||||
|
||||
def get_equip_(self, obj):
|
||||
|
|
|
@ -616,7 +616,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
|||
omos = OperationMaterial.objects.filter(operation=op,
|
||||
type=SubprodctionMaterial.SUB_MA_TYPE_OUT)
|
||||
sps_omo_l = omos.filter(use_scrap=False).values_list('subproduction_plan', flat=True)
|
||||
if set(list(sps_omi_l)) == set(list(sps_omo_l)) or op.step.type == Step.STEP_TYPE_COMB:
|
||||
if set(list(sps_omi_l)) == set(list(sps_omo_l)) and op.step.type == Step.STEP_TYPE_DIV:
|
||||
pass
|
||||
else:
|
||||
raise exceptions.APIException('消耗与产出不一致')
|
||||
|
|
Loading…
Reference in New Issue