Skip to content

Commit

Permalink
Ensure manufacturer_part.part matches part.pk
Browse files Browse the repository at this point in the history
  • Loading branch information
30350n committed Jan 10, 2024
1 parent bf90318 commit d7248b7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions inventree_part_import/part_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def import_supplier_part(self, supplier: Company, api_part: ApiPart, part: Part
if supplier_part and supplier_part.manufacturer_part is not None:
manufacturer_part = ManufacturerPart(self.api, supplier_part.manufacturer_part)
elif manufacturer_part := get_manufacturer_part(self.api, api_part.MPN):
if part and manufacturer_part.part != part.pk:
update_object_data(manufacturer_part, {"part": part.pk})
pass
elif self.existing_manufacturer_part:
manufacturer_part = self.existing_manufacturer_part
else:
Expand All @@ -164,6 +163,8 @@ def import_supplier_part(self, supplier: Company, api_part: ApiPart, part: Part
if not self.dry_run:
if not part:
part = Part(self.api, manufacturer_part.part)
elif part.pk != manufacturer_part.part:
update_object_data(manufacturer_part, {"part": part.pk})

if update_part:
if not api_part.finalize():
Expand Down

0 comments on commit d7248b7

Please sign in to comment.