30350n / inventree_part_import

CLI to import parts from suppliers like DigiKey, LCSC, Mouser, etc. to InvenTree
MIT License
28 stars 8 forks source link

AssertionError when multiple supplier parts exist with the same SKU #33

Closed ondras12345 closed 5 months ago

ondras12345 commented 6 months ago
  1. Import a part
  2. Manually create a new supplier part for it in inventree. Link it to a different supplier (company), but use the same SKU as the automatically imported supplier part.
  3. Try to update the part by importing it again
  4. Observe assertion error from this function: https://github.com/30350n/inventree_part_import/blob/14b62e821fc2bae64cdad8ed1589f4b07132bc0a/inventree_part_import/inventree_helpers.py#L23-L29

It seems to only match parts based on the SKU. I believe it should also use the supplier (company) - the caller function import_supplier_part does have that information available. Btw the (incorrect) type annotation inventree_api: InventreeCompany suggests that this was perhaps planned at some point, but never got implemented.

30350n commented 6 months ago

Should be fixed!

(I implemented this so that the company check only happens, if multiple SupplierParts with the same SKU exist. I think I prefer that behavior.)

ondras12345 commented 5 months ago

Thanks! Now it's working.