From 82f73276ba223c09f0c9fae5b22845bc13dcac79 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 8 Jan 2022 19:51:47 -0600 Subject: [PATCH] Refactor some importer method calls to avoid deprecation warnings --- rattail_corepos/importing/corepos/api.py | 40 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/rattail_corepos/importing/corepos/api.py b/rattail_corepos/importing/corepos/api.py index 003fbb9..728a380 100644 --- a/rattail_corepos/importing/corepos/api.py +++ b/rattail_corepos/importing/corepos/api.py @@ -172,7 +172,9 @@ class PersonImporter(FromCOREPOSAPI, corepos_importing.model.PersonImporter): super(PersonImporter, self).setup() 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): @@ -271,15 +273,20 @@ class CustomerPersonImporter(FromCOREPOSAPI, importing.model.CustomerPersonImpor query = self.session.query(model.Customer)\ .join(model.CoreCustomer) - self.customers = self.cache_model(model.Customer, query=query, - key='corepos_account_id') + self.customers = self.app.cache_model(self.session, + model.Customer, + query=query, + key='corepos_account_id') query = self.session.query(model.Person)\ .join(model.CorePerson)\ .filter(model.CorePerson.corepos_customer_id != None) - self.people = self.cache_model(model.Person, query=query, - key='corepos_customer_id', - query_options=[orm.joinedload(model.Person._corepos)]) + self.people = self.app.cache_model( + self.session, + model.Person, + key='corepos_customer_id', + query=query, + query_options=[orm.joinedload(model.Person._corepos)]) def get_host_objects(self): @@ -491,8 +498,10 @@ class ProductImporter(FromCOREPOSAPI, corepos_importing.model.ProductImporter): .join(model.CoreProduct)\ .filter(model.CoreProduct.corepos_id != None)\ .options(orm.joinedload(model.Product._corepos)) - self.core_existing = self.cache_model(model.Product, key='corepos_id', - query=query) + self.core_existing = self.app.cache_model(self.session, + model.Product, + key='corepos_id', + query=query) self.vendor_items_by_upc = {} @@ -671,8 +680,10 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp query = self.session.query(model.Vendor)\ .join(model.CoreVendor)\ .filter(model.CoreVendor.corepos_id != None) - self.vendors = self.cache_model(model.Vendor, query=query, - key='corepos_id') + self.vendors = self.app.cache_model(self.session, + model.Vendor, + query=query, + key='corepos_id') self.corepos_products = {} @@ -682,8 +693,9 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp self.progress_loop(cache, self.api.get_products(), message="Caching Products from CORE-POS API") - self.products_by_item_id = self.cache_model(model.Product, - key='item_id') + self.products_by_item_id = self.app.cache_model(self.session, + model.Product, + key='item_id') def get_host_objects(self): return self.api.get_vendor_items() @@ -788,7 +800,9 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter): def setup(self): super(MemberImporter, self).setup() 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): return self.get_core_members()