Refactor some importer method calls to avoid deprecation warnings

This commit is contained in:
Lance Edgar 2022-01-08 19:51:47 -06:00
parent 1f3ab43e91
commit 82f73276ba

View file

@ -172,7 +172,9 @@ class PersonImporter(FromCOREPOSAPI, corepos_importing.model.PersonImporter):
super(PersonImporter, self).setup() super(PersonImporter, self).setup()
model = self.config.get_model() model = self.config.get_model()
self.customers = self.cache_model(model.Customer, key='id') self.customers = self.app.cache_model(self.session,
model.Customer,
key='id')
def get_host_objects(self): def get_host_objects(self):
@ -271,14 +273,19 @@ class CustomerPersonImporter(FromCOREPOSAPI, importing.model.CustomerPersonImpor
query = self.session.query(model.Customer)\ query = self.session.query(model.Customer)\
.join(model.CoreCustomer) .join(model.CoreCustomer)
self.customers = self.cache_model(model.Customer, query=query, self.customers = self.app.cache_model(self.session,
model.Customer,
query=query,
key='corepos_account_id') key='corepos_account_id')
query = self.session.query(model.Person)\ query = self.session.query(model.Person)\
.join(model.CorePerson)\ .join(model.CorePerson)\
.filter(model.CorePerson.corepos_customer_id != None) .filter(model.CorePerson.corepos_customer_id != None)
self.people = self.cache_model(model.Person, query=query, self.people = self.app.cache_model(
self.session,
model.Person,
key='corepos_customer_id', key='corepos_customer_id',
query=query,
query_options=[orm.joinedload(model.Person._corepos)]) query_options=[orm.joinedload(model.Person._corepos)])
def get_host_objects(self): def get_host_objects(self):
@ -491,7 +498,9 @@ class ProductImporter(FromCOREPOSAPI, corepos_importing.model.ProductImporter):
.join(model.CoreProduct)\ .join(model.CoreProduct)\
.filter(model.CoreProduct.corepos_id != None)\ .filter(model.CoreProduct.corepos_id != None)\
.options(orm.joinedload(model.Product._corepos)) .options(orm.joinedload(model.Product._corepos))
self.core_existing = self.cache_model(model.Product, key='corepos_id', self.core_existing = self.app.cache_model(self.session,
model.Product,
key='corepos_id',
query=query) query=query)
self.vendor_items_by_upc = {} self.vendor_items_by_upc = {}
@ -671,7 +680,9 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp
query = self.session.query(model.Vendor)\ query = self.session.query(model.Vendor)\
.join(model.CoreVendor)\ .join(model.CoreVendor)\
.filter(model.CoreVendor.corepos_id != None) .filter(model.CoreVendor.corepos_id != None)
self.vendors = self.cache_model(model.Vendor, query=query, self.vendors = self.app.cache_model(self.session,
model.Vendor,
query=query,
key='corepos_id') key='corepos_id')
self.corepos_products = {} self.corepos_products = {}
@ -682,7 +693,8 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp
self.progress_loop(cache, self.api.get_products(), self.progress_loop(cache, self.api.get_products(),
message="Caching Products from CORE-POS API") message="Caching Products from CORE-POS API")
self.products_by_item_id = self.cache_model(model.Product, self.products_by_item_id = self.app.cache_model(self.session,
model.Product,
key='item_id') key='item_id')
def get_host_objects(self): def get_host_objects(self):
@ -788,7 +800,9 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter):
def setup(self): def setup(self):
super(MemberImporter, self).setup() super(MemberImporter, self).setup()
model = self.config.get_model() model = self.config.get_model()
self.customers = self.cache_model(model.Customer, key='number') self.customers = self.app.cache_model(self.session,
model.Customer,
key='number')
def get_host_objects(self): def get_host_objects(self):
return self.get_core_members() return self.get_core_members()