fix: avoid error when CORE API gives record with no upc
This commit is contained in:
parent
d52a8704b7
commit
03bc03c9b8
|
@ -528,11 +528,12 @@ class ProductImporter(FromCOREPOSAPI, corepos_importing.model.ProductImporter):
|
||||||
products = OrderedDict()
|
products = OrderedDict()
|
||||||
|
|
||||||
def collect(product, i):
|
def collect(product, i):
|
||||||
if product['upc'] in products:
|
if product.get('upc'):
|
||||||
log.warning("duplicate UPC encountered for '%s'; will discard: %s",
|
if product['upc'] in products:
|
||||||
product['upc'], product)
|
log.warning("duplicate UPC encountered for '%s'; will discard: %s",
|
||||||
else:
|
product['upc'], product)
|
||||||
products[product['upc']] = product
|
else:
|
||||||
|
products[product['upc']] = product
|
||||||
|
|
||||||
self.progress_loop(collect, self.api.get_products(),
|
self.progress_loop(collect, self.api.get_products(),
|
||||||
message="Fetching product info from CORE-POS")
|
message="Fetching product info from CORE-POS")
|
||||||
|
@ -755,7 +756,7 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp
|
||||||
warn_for_missing_vendor_id = self.should_warn_for_missing_vendor_id()
|
warn_for_missing_vendor_id = self.should_warn_for_missing_vendor_id()
|
||||||
|
|
||||||
def cache(item, i):
|
def cache(item, i):
|
||||||
if not item['upc']:
|
if not item.get('upc'):
|
||||||
log.warning("CORE vendor item has no upc: %s", item)
|
log.warning("CORE vendor item has no upc: %s", item)
|
||||||
return
|
return
|
||||||
if item['vendorID'] == '0':
|
if item['vendorID'] == '0':
|
||||||
|
|
Loading…
Reference in a new issue