Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent crashes caused by leading spaces and parts without parameters #219

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions kintree/database/inventree_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ def translate_form_to_inventree(part_info: dict, category_tree: list, is_custom=
inventree_part['pricing'] = part_info.get('pricing', {})
inventree_part['currency'] = part_info.get('currency', 'USD')

parameters = part_info.get('parameters', {})

# Load parameters map
if category_tree:
parameter_map = config_interface.load_category_parameters(
Expand All @@ -335,7 +337,7 @@ def translate_form_to_inventree(part_info: dict, category_tree: list, is_custom=
parameter_value = part_tools.clean_parameter_value(
category=category_tree[0],
name=supplier_param,
value=part_info['parameters'][supplier_param],
value=parameters[supplier_param],
)
inventree_part['parameters'][inventree_param] = parameter_value
except KeyError:
Expand All @@ -354,7 +356,7 @@ def translate_form_to_inventree(part_info: dict, category_tree: list, is_custom=

# Check for extra parameters which weren't mapped
parameters_unmapped = []
for search_param in part_info['parameters'].keys():
for search_param in parameters.keys():
if search_param not in parameter_map.keys():
parameters_unmapped.append(search_param)

Expand Down
1 change: 1 addition & 0 deletions kintree/gui/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def run_search(self, e):
message=error_msg,
)
else:
self.fields['part_number'].value = self.fields['part_number'].value.strip()
self.page.splash.visible = True
self.page.update()

Expand Down
Loading