def create_some_fake_parts(organization): (pc1, pc2, pc3) = create_some_fake_part_classes() (m1, m2, m3) = create_some_fake_manufacturers(organization=organization) pt1 = Part(number_class=pc2, number_item='3333', organization=organization) pt1.save() mp1 = ManufacturerPart(part=pt1, manufacturer=m1, manufacturer_part_number='STM32F401CEU6') mp1.save() pt1.primary_manufacturer_part = mp1 pt1.save() assy = create_a_fake_assembly() pch1 = create_a_fake_part_change_history(part=pt1, assembly=assy) pt2 = Part(number_class=pc1, organization=organization) pt2.save() mp2 = ManufacturerPart(part=pt2, manufacturer=None, manufacturer_part_number='GRM1555C1H100JA01D') mp2.save() pt2.primary_manufacturer_part = mp2 pt2.save() assy2 = create_a_fake_assembly_with_subpart(part_change_history=pch1) pch2 = create_a_fake_part_change_history(part=pt2, assembly=assy2) pt3 = Part(number_class=pc3, organization=organization) pt3.save() mp3 = ManufacturerPart(part=pt3, manufacturer=m3, manufacturer_part_number='NRF51822') mp3.save() assy3 = create_a_fake_assembly_with_subpart(part_change_history=pch2) subpart3 = create_a_fake_subpart(pch1, count=10, reference="") assy3.subparts.add(subpart3) create_a_fake_part_change_history(part=pt3, assembly=assy3) create_a_fake_part_change_history(part=pt3, assembly=assy3) # Create a part with no PartChangeHistory pt4 = Part(number_class=pc1, number_item='4444', organization=organization) pt4.save() # Create a part with a PartChangeHistory with no assembly pt5 = Part(number_class=pc1, number_item='5555', organization=organization) pt5.save() create_a_fake_part_change_history(pt5, None) (s1, s2, s3) = create_some_fake_sellers(organization=organization) create_a_fake_seller_part(s1, mp1, moq=None, mpq=None, unit_cost=None, lead_time_days=None) create_a_fake_seller_part(s1, mp1, moq=1, mpq=1, unit_cost=1.2, lead_time_days=20, nre_cost=500) create_a_fake_seller_part( s2, mp1, moq=1000, mpq=5000, unit_cost=0.1005, lead_time_days=7, ) create_a_fake_seller_part(s2, mp2, moq=200, mpq=200, unit_cost=0.5, lead_time_days=47, nre_cost=1) return pt1, pt2, pt3, pt4
def create_some_fake_semi_intelligent_parts(organization): (pc1, pc2, pc3) = create_some_fake_part_classes(organization=organization) pt1 = Part(number_class=pc2, number_item='3333', organization=organization) pt1.save() pt2 = Part(number_class=pc1, organization=organization) pt2.save() pt3 = Part(number_class=pc3, organization=organization) pt3.save() # pt4 is a part with no PartRevision pt4 = Part(number_class=pc1, number_item='4444', organization=organization) pt4.save(no_part_revision=True) pt5 = Part(number_class=pc1, number_item='5555', organization=organization) pt5.save() return pt1, pt2, pt3, pt4, pt5
def create_some_fake_intelligent_parts(organization): pt1 = Part(number_item=('3' * organization.number_item_len), organization=organization) pt1.save() pt2 = Part(number_item='4' * organization.number_item_len, organization=organization) pt2.save() pt3 = Part(number_item='A' * organization.number_item_len, organization=organization) pt3.save() # pt4 is a part with no PartRevision pt4 = Part(number_item='B' * organization.number_item_len, organization=organization) pt4.save(no_part_revision=True) pt5 = Part(number_item='5' * organization.number_item_len, organization=organization) pt5.save() return pt1, pt2, pt3, pt4, pt5
def create_some_fake_parts(organization): (pc1, pc2, pc3) = create_some_fake_part_classes() (m1, m2, m3) = create_some_fake_manufacturers(organization=organization) pt1 = Part(number_class=pc2, number_item='3333', description='Brown dog', revision='1', organization=organization) pt1.save() mp1 = ManufacturerPart(part=pt1, manufacturer=m1, manufacturer_part_number='STM32F401CEU6') mp1.save() pt1.primary_manufacturer_part = mp1 pt1.save() pt2 = Part(number_class=pc1, description='', organization=organization) pt2.save() mp2 = ManufacturerPart(part=pt2, manufacturer=None, manufacturer_part_number='GRM1555C1H100JA01D') mp2.save() pt2.primary_manufacturer_part = mp2 pt2.save() pt3 = Part(number_class=pc3, description='Friendly ghost', organization=organization) pt3.save() mp3 = ManufacturerPart(part=pt3, manufacturer=m3, manufacturer_part_number='NRF51822') mp3.save() create_a_fake_subpart(pt1, pt2) create_a_fake_subpart(pt1, pt3, count=10) (s1, s2, s3) = create_some_fake_sellers(organization=organization) create_a_fake_seller_part(s1, mp1, moq=None, mpq=None, unit_cost=None, lead_time_days=None) create_a_fake_seller_part(s1, mp1, moq=1, mpq=1, unit_cost=1.2, lead_time_days=20, nre_cost=500) create_a_fake_seller_part( s2, mp1, moq=1000, mpq=5000, unit_cost=0.1005, lead_time_days=7, ) create_a_fake_seller_part(s2, mp2, moq=200, mpq=200, unit_cost=0.5, lead_time_days=47, nre_cost=1) return pt1, pt2, pt3
def create_some_fake_parts(organization): (pc1, pc2, pc3) = create_some_fake_part_classes() (m1, m2, m3) = create_some_fake_manufacturers(organization=organization) pt1 = Part( number_class=pc2, number_item='3333', organization=organization) pt1.save() mp1 = ManufacturerPart(part=pt1, manufacturer=m1, manufacturer_part_number='STM32F401CEU6') mp1.save() pt1.primary_manufacturer_part = mp1 pt1.save() assy = create_a_fake_assembly() pr1 = create_a_fake_part_revision(part=pt1, assembly=assy) pt2 = Part( number_class=pc1, organization=organization) pt2.save() mp2 = ManufacturerPart(part=pt2, manufacturer=None, manufacturer_part_number='GRM1555C1H100JA01D') mp2.save() pt2.primary_manufacturer_part = mp2 pt2.save() assy2 = create_a_fake_assembly_with_subpart(part_revision=pr1) pr2 = create_a_fake_part_revision(part=pt2, assembly=assy2) pt3 = Part(number_class=pc3, organization=organization) pt3.save() mp3 = ManufacturerPart(part=pt3, manufacturer=m3, manufacturer_part_number='NRF51822') mp3.save() assy3 = create_a_fake_assembly_with_subpart(part_revision=pr2) subpart3 = create_a_fake_subpart(pr1, count=10, reference="") assy3.subparts.add(subpart3) assy3.save() create_a_fake_part_revision(part=pt3, assembly=assy3) create_a_fake_part_revision(part=pt3, assembly=assy3, revision="2") # Create a part with no PartRevision pt4 = Part(number_class=pc1, number_item='4444', organization=organization) pt4.save(no_part_revision=True) # Create a part with a PartRevision with no assembly - no longer happens due to PartRevision save override pt5 = Part(number_class=pc1, number_item='5555', organization=organization) pt5.save() create_a_fake_part_revision(pt5, None) (s1, s2, s3) = create_some_fake_sellers(organization=organization) create_a_fake_seller_part( s1, mp1, moq=1, mpq=1, unit_cost=0, lead_time_days=None, nre_cost=0,) create_a_fake_seller_part( s1, mp1, moq=1, mpq=1, unit_cost=1.2, lead_time_days=20, nre_cost=500) create_a_fake_seller_part( s2, mp1, moq=1000, mpq=5000, unit_cost=0.1005, lead_time_days=7, nre_cost=0,) create_a_fake_seller_part( s2, mp2, moq=200, mpq=200, unit_cost=0.5, lead_time_days=47, nre_cost=1) return pt1, pt2, pt3, pt4
def create_some_fake_parts(organization): (pc1, pc2, pc3) = create_some_fake_part_classes() (m1, m2, m3) = create_some_fake_manufacturers(organization=organization) pt1 = Part(manufacturer_part_number='STM32F401CEU6', number_class=pc2, number_item='3333', description='Brown dog', revision='1', manufacturer=m1, organization=organization) pt1.save() pt2 = Part(manufacturer_part_number='GRM1555C1H100JA01D', number_class=pc1, description='', manufacturer=None, organization=organization) pt2.save() pt3 = Part(manufacturer_part_number='NRF51822', number_class=pc3, description='Friendly ghost', manufacturer=m3, organization=organization) pt3.save() create_a_fake_subpart(pt1, pt2) create_a_fake_subpart(pt1, pt3, count=10) (s1, s2, s3) = create_some_fake_sellers(organization=organization) create_a_fake_seller_part(s1, pt1, moq=None, mpq=None, unit_cost=None, lead_time_days=None) create_a_fake_seller_part(s2, pt1, moq=1000, mpq=5000, unit_cost=0.1005, lead_time_days=7) create_a_fake_seller_part(s2, pt2, moq=200, mpq=200, unit_cost=0, lead_time_days=47) return pt1, pt2, pt3