Provide fall back date when sorting, to avoid None
This commit is contained in:
parent
2e5f7d3cd5
commit
d00e3b6312
|
@ -24,6 +24,7 @@
|
||||||
CORE-POS -> Catapult Inventory Workbook
|
CORE-POS -> Catapult Inventory Workbook
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from sqlalchemy.exc import ProgrammingError
|
from sqlalchemy.exc import ProgrammingError
|
||||||
|
@ -117,6 +118,9 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(InventoryItemImporter, self).setup()
|
super(InventoryItemImporter, self).setup()
|
||||||
|
|
||||||
|
# this is used for sorting, when a value has no date
|
||||||
|
self.old_date = datetime.date(1900, 1, 1)
|
||||||
|
|
||||||
self.ignored_upcs = self.config.getlist(
|
self.ignored_upcs = self.config.getlist(
|
||||||
'corepos', 'exporting.catapult_inventory.ignored_upcs')
|
'corepos', 'exporting.catapult_inventory.ignored_upcs')
|
||||||
|
|
||||||
|
@ -341,7 +345,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
product.upc, len(vendor_items), product)
|
product.upc, len(vendor_items), product)
|
||||||
|
|
||||||
# sort the list so most recently modified is first
|
# sort the list so most recently modified is first
|
||||||
vendor_items.sort(key=lambda item: item.modified,
|
vendor_items.sort(key=lambda item: item.modified or self.old_date,
|
||||||
reverse=True)
|
reverse=True)
|
||||||
|
|
||||||
# use the "first" vendor item available
|
# use the "first" vendor item available
|
||||||
|
|
Loading…
Reference in a new issue