Skip to content

Commit

Permalink
fix field null bug (#291)
Browse files Browse the repository at this point in the history
* fix field null bug

* simplyfy
  • Loading branch information
MoriatyC authored and Time1ess committed Jan 18, 2018
1 parent ee0aa99 commit 27ee116
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Process/models/quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand 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)

Expand Down

0 comments on commit 27ee116

Please sign in to comment.