rattail-demo/rattail_demo/importing/corepos_api.py
Lance Edgar 4288e1ce64 Override the CORE-API -> Rattail Demo importer for Store data
this lets the demo have random extra Store records and the importer will just
ignore them
2021-01-28 13:29:22 -06:00

32 lines
914 B
Python

# -*- coding: utf-8; -*-
"""
CORE-POS API -> Rattail Demo importing
"""
from rattail_corepos.importing.corepos import api as base
class FromCOREPOSToRattail(base.FromCOREPOSToRattail):
"""
Override some parts of CORE-POS API -> Rattail importing.
"""
def get_importers(self):
importers = super(FromCOREPOSToRattail, self).get_importers()
importers['Store'] = StoreImporter
return importers
class StoreImporter(base.StoreImporter):
"""
Tweak how we import Store data from CORE-POS API.
"""
def cache_query(self):
model = self.model
# we ignore any Store records which are not associated with CORE, so
# the importer will never be tempted to delete them etc.
return self.session.query(model.Store)\
.join(model.CoreStore)\
.filter(model.CoreStore.corepos_id != None)