Add 'memo' field to Catapult export
This commit is contained in:
parent
c5e618d517
commit
e3204993b1
|
@ -106,7 +106,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
# 'pf6',
|
# 'pf6',
|
||||||
# 'pf7',
|
# 'pf7',
|
||||||
# 'pf8',
|
# 'pf8',
|
||||||
# 'memo',
|
'memo',
|
||||||
'scale_shelf_life',
|
'scale_shelf_life',
|
||||||
'scale_shelf_life_type',
|
'scale_shelf_life_type',
|
||||||
'scale_ingredient_text',
|
'scale_ingredient_text',
|
||||||
|
@ -134,6 +134,10 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
'corepos', 'exporting.catapult_inventory.warn_no_valid_vendor_items',
|
'corepos', 'exporting.catapult_inventory.warn_no_valid_vendor_items',
|
||||||
default=True)
|
default=True)
|
||||||
|
|
||||||
|
self.warn_truncated_memo = self.config.getbool(
|
||||||
|
'corepos', 'exporting.catapult_inventory.warn_truncated_memo',
|
||||||
|
default=True)
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
query = self.host_session.query(corepos.Product)\
|
query = self.host_session.query(corepos.Product)\
|
||||||
.order_by(corepos.Product.upc)\
|
.order_by(corepos.Product.upc)\
|
||||||
|
@ -142,7 +146,8 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
.options(orm.joinedload(corepos.Product.vendor_items)\
|
.options(orm.joinedload(corepos.Product.vendor_items)\
|
||||||
.joinedload(corepos.VendorItem.vendor))\
|
.joinedload(corepos.VendorItem.vendor))\
|
||||||
.options(orm.joinedload(corepos.Product.default_vendor))\
|
.options(orm.joinedload(corepos.Product.default_vendor))\
|
||||||
.options(orm.joinedload(corepos.Product.scale_item))
|
.options(orm.joinedload(corepos.Product.scale_item))\
|
||||||
|
.options(orm.joinedload(corepos.Product.user_info))
|
||||||
return query
|
return query
|
||||||
|
|
||||||
def normalize_host_object(self, product):
|
def normalize_host_object(self, product):
|
||||||
|
@ -312,6 +317,15 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
else:
|
else:
|
||||||
supplier_unit = 'CS'
|
supplier_unit = 'CS'
|
||||||
|
|
||||||
|
memo = None
|
||||||
|
if product.user_info and product.user_info.long_text is not None:
|
||||||
|
memo = str(product.user_info.long_text)
|
||||||
|
if memo and len(memo) > 254:
|
||||||
|
logger = log.warning if self.warn_truncated_memo else log.debug
|
||||||
|
logger("product %s has memo of length %s; will truncate: %s",
|
||||||
|
product.upc, len(memo), memo)
|
||||||
|
memo = memo[:254]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'item_id': item_id,
|
'item_id': item_id,
|
||||||
'dept_id': department.number,
|
'dept_id': department.number,
|
||||||
|
@ -376,9 +390,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
# 'pf7',
|
# 'pf7',
|
||||||
# 'pf8',
|
# 'pf8',
|
||||||
|
|
||||||
# TODO: does CORE have this?
|
'memo': memo,
|
||||||
# 'memo': None,
|
|
||||||
|
|
||||||
'scale_shelf_life': scale_item.shelf_life if scale_item else None,
|
'scale_shelf_life': scale_item.shelf_life if scale_item else None,
|
||||||
'scale_shelf_life_type': 0 if scale_item else None,
|
'scale_shelf_life_type': 0 if scale_item else None,
|
||||||
'scale_ingredient_text': scale_ingredient_text,
|
'scale_ingredient_text': scale_ingredient_text,
|
||||||
|
|
Loading…
Reference in a new issue