Use subdept. number and name for pf1 field in Catapult export

This commit is contained in:
Lance Edgar 2020-04-08 16:13:51 -05:00
parent c3ecf828fc
commit c330cfccb5

View file

@ -128,6 +128,10 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
'corepos', 'exporting.catapult_inventory.warn_missing_department', 'corepos', 'exporting.catapult_inventory.warn_missing_department',
default=True) default=True)
self.warn_empty_subdepartment = self.config.getbool(
'corepos', 'exporting.catapult_inventory.warn_empty_subdepartment',
default=True)
self.warn_truncated_receipt_alias = self.config.getbool( self.warn_truncated_receipt_alias = self.config.getbool(
'corepos', 'exporting.catapult_inventory.warn_truncated_receipt_alias', 'corepos', 'exporting.catapult_inventory.warn_truncated_receipt_alias',
default=True) default=True)
@ -367,6 +371,16 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
else: else:
supplier_unit = 'CS' supplier_unit = 'CS'
pf1 = None
if product.subdepartment:
if not product.subdepartment.number:
logger = log.warning if self.warn_empty_subdepartment else log.debug
logger("product %s has 'empty' subdepartment number: %s",
product.upc, product)
else:
pf1 = "{} {}".format(product.subdepartment.number,
product.subdepartment.name)
memo = None memo = None
if product.user_info and product.user_info.long_text is not None: if product.user_info and product.user_info.long_text is not None:
memo = str(product.user_info.long_text) memo = str(product.user_info.long_text)
@ -439,7 +453,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
# 'cs_pk_multiplier': None, # 'cs_pk_multiplier': None,
# 'dsd': None, # 'dsd': None,
'pf1': product.subdepartment.number if product.subdepartment else None, 'pf1': pf1,
# TODO: are these needed? # TODO: are these needed?
# 'pf2', # 'pf2',