Add 'location' to Catapult export
This commit is contained in:
parent
d87c889d26
commit
e71e06f837
|
@ -26,6 +26,7 @@ CORE-POS -> Catapult Inventory Workbook
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from sqlalchemy.exc import ProgrammingError
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
||||||
from corepos import enum as corepos_enum
|
from corepos import enum as corepos_enum
|
||||||
|
@ -85,7 +86,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
'spec_tend_1',
|
'spec_tend_1',
|
||||||
'spec_tend_2',
|
'spec_tend_2',
|
||||||
'age_required',
|
'age_required',
|
||||||
# 'location',
|
'location',
|
||||||
# 'family_line',
|
# 'family_line',
|
||||||
'alt_id',
|
'alt_id',
|
||||||
'alt_receipt_alias',
|
'alt_receipt_alias',
|
||||||
|
@ -138,6 +139,16 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
'corepos', 'exporting.catapult_inventory.warn_truncated_memo',
|
'corepos', 'exporting.catapult_inventory.warn_truncated_memo',
|
||||||
default=True)
|
default=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.host_session.query(corepos.FloorSection).count()
|
||||||
|
except ProgrammingError as error:
|
||||||
|
if "doesn't exist" in str(error):
|
||||||
|
self.floor_sections_exist = False
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
self.floor_sections_exist = 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)\
|
||||||
|
@ -148,6 +159,9 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
.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))
|
.options(orm.joinedload(corepos.Product.user_info))
|
||||||
|
if self.floor_sections_exist:
|
||||||
|
query = query.options(orm.joinedload(corepos.Product.physical_location)\
|
||||||
|
.joinedload(corepos.ProductPhysicalLocation.floor_section))
|
||||||
return query
|
return query
|
||||||
|
|
||||||
def normalize_host_object(self, product):
|
def normalize_host_object(self, product):
|
||||||
|
@ -230,6 +244,14 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
# if tax_rate_ids_2 and rate.id in tax_rate_ids_2:
|
# if tax_rate_ids_2 and rate.id in tax_rate_ids_2:
|
||||||
# tax_2 += rate.rate
|
# tax_2 += rate.rate
|
||||||
|
|
||||||
|
location = None
|
||||||
|
if self.floor_sections_exist and product.physical_location and product.physical_location.floor_section:
|
||||||
|
location = product.physical_location.floor_section.name
|
||||||
|
if len(location) > 30:
|
||||||
|
log.warning("product %s has location length %s; will truncate: %s",
|
||||||
|
product.upc, len(location), location)
|
||||||
|
location = location[:30]
|
||||||
|
|
||||||
# no alt item (or auto discount) by default
|
# no alt item (or auto discount) by default
|
||||||
alt_id = None
|
alt_id = None
|
||||||
alt_receipt_alias = None
|
alt_receipt_alias = None
|
||||||
|
@ -361,9 +383,9 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
'spec_tend_1': 'EBT' if product.foodstamp else None,
|
'spec_tend_1': 'EBT' if product.foodstamp else None,
|
||||||
'spec_tend_2': 'WIC' if product.wicable else None,
|
'spec_tend_2': 'WIC' if product.wicable else None,
|
||||||
'age_required': product.id_enforced or None,
|
'age_required': product.id_enforced or None,
|
||||||
|
'location': location,
|
||||||
|
|
||||||
# TODO: does CORE have these?
|
# TODO: does CORE have these?
|
||||||
# 'location': None,
|
|
||||||
# 'family_line': None,
|
# 'family_line': None,
|
||||||
|
|
||||||
'alt_id': alt_id,
|
'alt_id': alt_id,
|
||||||
|
|
Loading…
Reference in a new issue