Closed ondras12345 closed 3 months ago
Went with what's probably the simplest fix: If there's no MPN, just use the TME SKU.
Thanks for your donation btw! 😊
Thanks! That did the trick for parts that were missing MPN but had a valid manufacturer (e.g. https://www.tme.eu/en/details/to220-set/heatsinks-equipment/stonecold/).
However, that copper clad still fails to import, because it has an empty manufacturer name:
$ inventree-part-import -v -o tme LAM100X160EX1.5
setting up InvenTree API ...
loading api configuration from 'inventree.yaml' ...
(only 2 of 5 available supplier modules are configured)
loading pre creation hooks ...
successfully loaded 1 pre creation hooks!
setting up categories ...
[...]
successfully setup categories!
searching for LAM100X160EX1.5 ...
searching at TME ...
importing TME part LAM100X160EX1.5 ...
creating part LAM100X160EX1.5 in 'PCBs/Copper Laminates' ...
creating manufacturer '' ...
error: failed to import part with:
name: ['This field may not be blank.']
FULL TRACEBACK:
Traceback (most recent call last):
File "/home/ondra/.local/pipx/venvs/inventree-part-import/lib/python3.10/site-packages/inventree_part_import/part_importer.py", line 86, in import_part
import_result |= self.import_supplier_part(supplier, api_part, existing_part)
File "/home/ondra/.local/pipx/venvs/inventree-part-import/lib/python3.10/site-packages/inventree_part_import/part_importer.py", line 162, in import_supplier_part
result = self.create_manufacturer_part(api_part, part)
File "/home/ondra/.local/pipx/venvs/inventree-part-import/lib/python3.10/site-packages/inventree_part_import/part_importer.py", line 252, in create_manufacturer_part
manufacturer = create_manufacturer(self.api, api_part.manufacturer)
File "/home/ondra/.local/pipx/venvs/inventree-part-import/lib/python3.10/site-packages/inventree_part_import/inventree_helpers.py", line 98, in create_manufacturer
return InventreeCompany.create(inventree_api, {
File "/home/ondra/.local/pipx/venvs/inventree-part-import/lib/python3.10/site-packages/inventree/base.py", line 166, in create
response = api.post(cls.URL, data, **kwargs)
File "/home/ondra/.local/pipx/venvs/inventree-part-import/lib/python3.10/site-packages/inventree/api.py", line 426, in post
response = self.request(
File "/home/ondra/.local/pipx/venvs/inventree-part-import/lib/python3.10/site-packages/inventree_part_import/retries.py", line 68, in request
return super().request(api_url, **kwargs)
File "/home/ondra/.local/pipx/venvs/inventree-part-import/lib/python3.10/site-packages/inventree/api.py", line 378, in request
raise requests.exceptions.HTTPError(detail)
requests.exceptions.HTTPError: {'detail': 'Error occurred during API request', 'url': 'http://inventree.rpi.lab.lan/api/company/', 'method': 'POST', 'status_code': 400, 'body': '{"name":["This field may not be blank."]}', 'headers': {'AUTHORIZATION': 'Token [REDACTED]'}, 'params': {'format': 'json'}, 'data': {'name': '', 'description': '', 'is_manufacturer': True, 'is_supplier': False, 'is_customer': False}}
the following parts failed to import:
LAM100X160EX1.5
Should be fixed now!
Thanks, that did it
TME lists some parts that do not have a manufacturer part number. Example: https://www.tme.eu/en/details/lam100x160ex1.5/two-layers-laminates/ I reported this to TME for parts where it was obviously a mistake (e.g. when there was a datasheet attached that clearly showed the manufacturer part number), but I keep finding more and more parts that have this problem, so I think it would be useful if it was possible to import them anyway. Btw I believe they might be doing it on purpose for some parts, e.g. the copper clad I linked above. Maybe they use a mix of manufacturer parts for the same supplier part.
This is what happens when I try to import such a part: