Skip to content

Cannot import BOM -- Invalid Type #9382

Closed

Description

@galmiklos

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

Trying to import a BOM to an assembly part from a csv file. I have all the parts added to the inventory, with the manufacturer part number as "Part". All rows show "Incorrect type. Expected pk value, received str."

Steps to Reproduce

  1. Create a part, assembly type.

  2. Click the "Import BOM Data" icon.

  3. Select csv file (attached for reference) and Submit.
    SmartPrintCoreH7x_BOM.csv

  4. Map the "Manufacturer_Part_Number" column to Component, and the "Qty" column to Quantity.
    Image

  5. Click Accept Column Mapping

All entries in the Component column are marked incorrect.

Image

Expected behaviour

I expect the BOM import to work with this csv file.

Deployment Method

  • Docker
  • Package
  • Bare metal
  • Other - added info in Steps to Reproduce

Version Information

InvenTree-Version: 0.18.0 dev
Django Version: 4.2.19
Commit Hash: 06961c6
Commit Date: 2025-03-07
Commit Branch: master
Database: mysql
Debug-Mode: False
Deployed using Docker: False
Platform: Linux-6.8.0-52-generic-x86_64-with-glibc2.35
Installer: GIT
Active plugins: [{"name":"InvenTreeBarcode","slug":"inventreebarcode","version":"2.1.0"},{"name":"InvenTreeCoreNotificationsPlugin","slug":"inventreecorenotificationsplugin","version":"1.0.0"},{"name":"InvenTreeCurrencyExchange","slug":"inventreecurrencyexchange","version":"1.0.0"},{"name":"InvenTreeLabel","slug":"inventreelabel","version":"1.1.0"},{"name":"InvenTreeLabelMachine","slug":"inventreelabelmachine","version":"1.0.0"},{"name":"InvenTreeLabelSheet","slug":"inventreelabelsheet","version":"1.0.0"},{"name":"DigiKeyPlugin","slug":"digikeyplugin","version":"1.0.0"},{"name":"LCSCPlugin","slug":"lcscplugin","version":"1.0.0"},{"name":"MouserPlugin","slug":"mouserplugin","version":"1.0.0"},{"name":"TMEPlugin","slug":"tmeplugin","version":"1.0.0"}]

Please verify if you can reproduce this bug on the demo site.

  • I can reproduce this bug on the demo site.

Relevant log output

Activity

  1. added
    bug
    question
    triage:not-checked
    on Mar 25, 2025
  2. SchrodingersGat commented on Mar 26, 2025

    @SchrodingersGat
    Member

    With the manufacturer part number as "Part"

    You cannot import based on MPN - the only mapping to an internal part is the "PK" (primary key / unique ID) for the part instance.

    There are some outstanding issues regarding adding support for import via "natural key lookup":

    However none of these have received any developer attention.

  3. galmiklos commented on Mar 26, 2025

    @galmiklos
    Author

    It works with 0.17.7, I can import the same BOM. I thought I could expect the same in the dev release, too.

    Image

    Image

    Image

    Most of the parts are not created in this instance of inventree, so there are only a few good hits, but those are marked "not matching part found". The existing parts are matched to the MPNs in the BOM.

  4. SchrodingersGat commented on Mar 26, 2025

    @SchrodingersGat
    Member

    @galmiklos the importer in stable is a completely different workflow and we have not yet been able to get natural key support working in the new implementation. There are a number of large architectural differences, overall the new importer is a much better solution but not all the features are ported yet

  5. gunstr commented on Mar 27, 2025

    @gunstr
    Contributor

    @galmiklos I have always used IPN for BoM import lookup why I'm in the same situation as you. As a workatound I have created a Python script using the Python Module where I add an Inventree pk column to each BoM csv file, then the import works as a charm.

    If you are more familiar with excel the same can be achieved by exporting all your parts to an excel table and use vlookup to populate a pk column in your BoM.

    As @SchrodingersGat mention the Inventree pk is currently the only implemented matching field why there is no way around than to add the same into your BoMs.

  6. added
    import / export
    and removed
    bug
    triage:not-checked
    on Mar 27, 2025
  7. galmiklos commented on Mar 30, 2025

    @galmiklos
    Author

    Thank you for the advice, for now I went back to the stable release, and imported my BOM. I am not closing this issue, in case you want to keep it to keep track of this "feature request", but of course, I consider it solved from my point of view.

    Thanks again!

  8. ius commented on Apr 12, 2025

    @ius

    A workaround for those using the InvenTree Kicad plugin: assuming all schematic parts are InvenTree sourced (ie. the InvenTree property contains the part PK) you can use a cli oneliner to generate a CSV file compatible with the BOM importer:

    kicad-cli sch export bom --labels 'PK,Qty' --fields 'InvenTree,${QUANTITY}' my_pcb.sch
    
  9. github-actions commented on Jun 12, 2025

    @github-actions
    Contributor

    This issue seems stale. Please react to show this is still important.

  10. added
    inactive
    on Jun 12, 2025
  11. galmiklos commented on Jun 15, 2025

    @galmiklos
    Author

    Yes, it is important, I would like to be able to import parts without having to know the PKs, just as it works now in the current stable release. I just kept this issue open, in case you needed it for tracking this "feature request", but of course, please feel free to close it, I don't have any immediate expectation.

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    import / exportinactivequestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions