From 03bc03c9b849d59683314c0c269e7896252032e9 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 10 Jul 2024 10:22:46 -0500 Subject: [PATCH] fix: avoid error when CORE API gives record with no upc --- rattail_corepos/importing/corepos/api.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rattail_corepos/importing/corepos/api.py b/rattail_corepos/importing/corepos/api.py index bfdd042..a495c79 100644 --- a/rattail_corepos/importing/corepos/api.py +++ b/rattail_corepos/importing/corepos/api.py @@ -528,11 +528,12 @@ class ProductImporter(FromCOREPOSAPI, corepos_importing.model.ProductImporter): products = OrderedDict() def collect(product, i): - if product['upc'] in products: - log.warning("duplicate UPC encountered for '%s'; will discard: %s", - product['upc'], product) - else: - products[product['upc']] = product + if product.get('upc'): + if product['upc'] in products: + log.warning("duplicate UPC encountered for '%s'; will discard: %s", + product['upc'], product) + else: + products[product['upc']] = product self.progress_loop(collect, self.api.get_products(), 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() def cache(item, i): - if not item['upc']: + if not item.get('upc'): log.warning("CORE vendor item has no upc: %s", item) return if item['vendorID'] == '0':