Skip to content

Commit

Permalink
Add setting for Mouser answer language
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeoLacruz committed Dec 29, 2024
1 parent 4bfa53d commit b4fa171
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion inventree_supplier_sync/mouser.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,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_sync/supplier_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class SupplierSyncPlugin(AppMixin, ScheduleMixin, SettingsMixin, PanelMixin, Inv
'name': 'Supplier API Key new',
'description': 'Place here your key for the suppliers 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',
},
'ENABLE_SYNC': {
'name': 'Enable the plugin',
'description': 'Allow the regular synchronisation',
Expand Down

0 comments on commit b4fa171

Please sign in to comment.