Skip to content

Commit

Permalink
Fix TME IndexError with unsupported currencies (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
30350n committed Jan 10, 2024
1 parent e98f22d commit 8b6e5f5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions inventree_part_import/suppliers/supplier_tme.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
class TME(Supplier):
def setup(self, api_token, api_secret, currency, language, location):
self.tme_api = TMEApi(api_token, api_secret, language, location, currency)
self.currency = currency
return True

def search(self, search_term):
tme_part = self.tme_api.get_product(search_term)
if tme_part:
tme_stock = self.tme_api.get_prices_and_stocks([tme_part["Symbol"]])[0]
tme_stocks = self.tme_api.get_prices_and_stocks([tme_part["Symbol"]])
tme_stock = tme_stocks[0] if tme_stocks else {}
return [self.get_api_part(tme_part, tme_stock)], 1

if not (results := self.tme_api.product_search(search_term)):
Expand Down Expand Up @@ -63,7 +63,7 @@ def get_api_part(self, tme_part, tme_stock):
category_path=self.tme_api.get_category_path(tme_part["CategoryId"]),
parameters=None,
price_breaks=price_breaks,
currency=self.currency,
currency=self.tme_api.currency,
)

api_part.finalize_hook = MethodType(self.finalize_hook, api_part)
Expand Down

0 comments on commit 8b6e5f5

Please sign in to comment.