From 5b1305ddbd74dae18e385f742c906ac32758e243 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 27 Jan 2021 09:28:35 -0600 Subject: [PATCH] Don't choke when vendorItems record has no modified timestamp --- rattail_corepos/importing/corepos/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rattail_corepos/importing/corepos/api.py b/rattail_corepos/importing/corepos/api.py index 98628c7..0956a12 100644 --- a/rattail_corepos/importing/corepos/api.py +++ b/rattail_corepos/importing/corepos/api.py @@ -575,7 +575,10 @@ class ProductImporter(FromCOREPOSAPI, corepos_importing.model.ProductImporter): # pseudo-default" vendorItems record def sortkey(item): - dt = datetime.datetime.strptime(item['modified'], '%Y-%m-%d %H:%M:%S') + modified = item.get('modified') + if not modified: + return datetime.datetime(1900, 1, 1) + dt = datetime.datetime.strptime(modified, '%Y-%m-%d %H:%M:%S') return dt items = sorted(items, key=sortkey, reverse=True)