diff --git a/Process/models/quota.py b/Process/models/quota.py index 890cecb..17aac99 100644 --- a/Process/models/quota.py +++ b/Process/models/quota.py @@ -1,4 +1,4 @@ -from django.db import models, transaction +from django.db import models from django.contrib.auth.models import User from Process import ( @@ -83,7 +83,8 @@ def createProcurementMaterial(self): procurement_material.category = \ item.process_material.material.category procurement_material.count = item.process_material.count - procurement_material.weight = item.process_material.weight + procurement_material.weight = \ + item.process_material.piece_weight or 0 procurement_material_list.append(procurement_material) else: for sub_order in work_order.subworkorder_set.all(): @@ -92,10 +93,16 @@ def createProcurementMaterial(self): procurement_material = ProcurementMaterial() procurement_material.sub_order = sub_order procurement_material.inventory_type = self.category - procurement_material.material_number = item.material.uid - procurement_material.category = item.material.category - procurement_material.count = item.count - procurement_material.weight = item.weight + if self.category != QUOTA_LIST_CATEGORY_AUXILIARY: + procurement_material.material_number = \ + item.material.uid + procurement_material.category = item.material.category + if self.category == QUOTA_LIST_CATEGORY_PRINCIPAL: + procurement_material.count = item.count + procurement_material.weight = item.weight + else: + procurement_material.weight = item.quota or 0 + procurement_material.count = 0 procurement_material_list.append(procurement_material) ProcurementMaterial.objects.bulk_create(procurement_material_list) diff --git a/Production/serializers/man_hour_message.py b/Production/serializers/man_hour_message.py index ba58140..0659ebe 100644 --- a/Production/serializers/man_hour_message.py +++ b/Production/serializers/man_hour_message.py @@ -4,8 +4,8 @@ class ManHourMessageSerializer(serializers.ModelSerializer): - sub_order = serializers.CharField(source='sub_material.sub_order', - read_only=True) + sub_order_uid = serializers.CharField(source='sub_material.sub_order.uid', + read_only=True) ticket_number = serializers.CharField( source='sub_material.material.ticket_number', read_only=True) step = serializers.CharField(source='process_step.step', @@ -23,7 +23,7 @@ class ManHourMessageSerializer(serializers.ModelSerializer): class Meta: model = ProcessDetail - fields = ('id', 'sub_order', 'ticket_number', 'work_group_name', + fields = ('id', 'sub_order_uid', 'ticket_number', 'work_group_name', 'step', 'man_hours', 'writer', 'quota_clerk', 'actual_finish_dt') read_only_fields = ('id', 'work_group_name', 'actual_finish_dt')