Skip to content

Commit

Permalink
Add setting four mouser answer language
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeoLacruz committed Dec 29, 2024
1 parent 3bc92b9 commit b497c54
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion inventree_supplier_panel/mouser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ def get_mouser_partdata(self, sku, options):
# ------------------------------- get_mouser_package --------------------------
# Extracts the available packages from the Mouser part data json
def get_mouser_package(self, part_data):

att_names = {'packaging': {'German': 'Verpackung', 'English': 'Packaging'}}
package = ''
try:
attributes = part_data['ProductAttributes']
except Exception:
return None
for att in attributes:
if att['AttributeName'] == 'Verpackung':
if att['AttributeName'] == att_names['packaging'][self.get_setting('MOUSERLANGUAGE')]:
package = package + att['AttributeValue'] + ', '
return (package)

Expand Down
7 changes: 7 additions & 0 deletions inventree_supplier_panel/supplier_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class SupplierCartPanel(PanelMixin, SettingsMixin, InvenTreePlugin, UrlsMixin):
'name': 'Mouser search API key',
'description': 'Place here your key for the Mouser search API',
},
'MOUSERLANGUAGE': {
'name': 'Mouser language',
'description': 'The language that Mouser uses to answer your requests',
'choices': [('English', 'Mouser answers in English'),
('German', 'Mouser answers in German')],
'default': 'German',
},
'DIGIKEY_CLIENT_ID': {
'name': 'Digikey ID',
'description': 'Client ID for Digikey',
Expand Down

0 comments on commit b497c54

Please sign in to comment.