Skip to content

Commit

Permalink
Fix hildogjr#386 - check by accepetd stock codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hildogjr committed Sep 2, 2019
1 parent d4466c3 commit 4ecc1de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion kicost/distributors/api_octopart.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def init_dist_dict():
})
# Update the `distributor_dict`with the available distributor in this module with the module is enabled.
# It can be not enabled by the GUI saved configurations.
if distributors_modules_dict['api_partinfo_kitspace']['enabled']:
if distributors_modules_dict['api_octopart']['enabled']:
distributor_dict.update(dists)


Expand Down
20 changes: 11 additions & 9 deletions kicost/distributors/api_partinfo_kitspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,19 +290,21 @@ def get_part_info(query, parts, distributor_info=None):
query = None
part_dist_use_manfpn = copy.copy(DISTRIBUTORS)

# Check if that part have stock code. KiCost will prioritize these codes under "manf#'
# that will be used for get information for the part hat were not filled with the
# distributor stock code. So this is chacked after the 'manf#' abov code.
# Check if that part have stock code that is accepted to use by this module (API).
# KiCost will prioritize these codes under "manf#" that will be used for get
#information for the part hat were not filled with the distributor stock code. So
# this is checked after the 'manf#' buv code.
for d in FIELDS_CAT:
part_stock = part.fields.get(d)
if part_stock:
part_catalogue_code_dist = d[:-1]
part_code_dist = list({k for k, v in dist_xlate.items() if v == part_catalogue_code_dist})[0]
query = {'sku': {'vendor': part_code_dist, 'part': part_stock}}
queries.append(query)
query_parts.append(part)
query_part_stock_code.append(part_catalogue_code_dist)
part_dist_use_manfpn.remove(part_catalogue_code_dist)
if part_catalogue_code_dist in distributors_modules_dict['api_partinfo_kitspace']['distributors']:
part_code_dist = list({k for k, v in dist_xlate.items() if v == part_catalogue_code_dist})[0]
query = {'sku': {'vendor': part_code_dist, 'part': part_stock}}
queries.append(query)
query_parts.append(part)
query_part_stock_code.append(part_catalogue_code_dist)
part_dist_use_manfpn.remove(part_catalogue_code_dist)

part_manf = part.fields.get('manf', '')
part_code = part.fields.get('manf#')
Expand Down

0 comments on commit 4ecc1de

Please sign in to comment.