Skip to content

Commit

Permalink
Merge 7c5d850 into f5be15b
Browse files Browse the repository at this point in the history
  • Loading branch information
eeintech committed Jan 13, 2022
2 parents f5be15b + 7c5d850 commit f952b84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion kintree/database/inventree_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def is_new_part(category_id: int, part_info: dict) -> int:
part_list.extend(subcategory.getParts())

# Extract parameter from part info
new_part_parameters = part_info['parameters']
# Verify parameters values are not empty
new_part_parameters = part_info['parameters'] if list(set(part_info['parameters'].values())) != ['-'] else None

template_list = ParameterTemplate.list(inventree_api)

Expand Down Expand Up @@ -161,6 +162,12 @@ def fetch_template_name(template_id):
compare = part_info['name'] == part.name and \
part_info['description'] == part.description and \
part_info['revision'] == part.revision

# Check if new manufacturer part
if not compare:
manufacturer = list(part_info['manufacturer'].keys())[0]
mpn = list(part_info['manufacturer'].values())[0][0]
compare = not is_new_manufacturer_part(manufacturer, mpn)

if compare:
cprint(f'\n[TREE]\tFound part match in database (pk = {part.pk})', silent=settings.HIDE_DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion kintree/database/inventree_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def inventree_create(part_info: dict, categories: list, kicad=False, symbol=None
cprint(f'[ERROR]\tCategories ({category_name} - {subcategory_name}) does not exist in InvenTree', silent=settings.SILENT)
else:
# Check if part already exists
part_pk = inventree_api.is_new_part(category_pk, inventree_part)
part_pk = inventree_api.is_new_part(category_select, inventree_part)
# Part exists
if part_pk > 0:
cprint('[INFO]\tPart already exists, skipping.', silent=settings.SILENT)
Expand Down

0 comments on commit f952b84

Please sign in to comment.