diff --git a/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py b/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py index 0e0d280..e4c8c4b 100644 --- a/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py +++ b/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py @@ -106,7 +106,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo # 'pf6', # 'pf7', # 'pf8', - # 'memo', + 'memo', 'scale_shelf_life', 'scale_shelf_life_type', 'scale_ingredient_text', @@ -134,6 +134,10 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo 'corepos', 'exporting.catapult_inventory.warn_no_valid_vendor_items', default=True) + self.warn_truncated_memo = self.config.getbool( + 'corepos', 'exporting.catapult_inventory.warn_truncated_memo', + default=True) + def query(self): query = self.host_session.query(corepos.Product)\ .order_by(corepos.Product.upc)\ @@ -142,7 +146,8 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo .options(orm.joinedload(corepos.Product.vendor_items)\ .joinedload(corepos.VendorItem.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 def normalize_host_object(self, product): @@ -312,6 +317,15 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo else: 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 { 'item_id': item_id, 'dept_id': department.number, @@ -376,9 +390,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo # 'pf7', # 'pf8', - # TODO: does CORE have this? - # 'memo': None, - + 'memo': memo, 'scale_shelf_life': scale_item.shelf_life if scale_item else None, 'scale_shelf_life_type': 0 if scale_item else None, 'scale_ingredient_text': scale_ingredient_text,