Add CORE Office -> Lane op importer for Department
This commit is contained in:
parent
710f629d9c
commit
980c2fa952
|
@ -37,6 +37,11 @@ from rattail_corepos.corepos.common.importing import ToCore
|
|||
from corepos.db.lane_op import model as corepos
|
||||
|
||||
|
||||
class DepartmentImporter(ToCore):
|
||||
model_class = corepos.Department
|
||||
key = 'number'
|
||||
|
||||
|
||||
class ProductImporter(ToCore):
|
||||
model_class = corepos.Product
|
||||
key = 'id'
|
||||
|
|
|
@ -71,6 +71,7 @@ class FromCoreOfficeToCoreLane(FromCoreOfficeHandler, ToCoreLaneHandler):
|
|||
|
||||
def get_importers(self):
|
||||
importers = OrderedDict()
|
||||
importers['Department'] = DepartmentImporter
|
||||
importers['Product'] = ProductImporter
|
||||
return importers
|
||||
|
||||
|
@ -81,6 +82,39 @@ class FromCore(importing.FromSQLAlchemy):
|
|||
"""
|
||||
|
||||
|
||||
class DepartmentImporter(FromCore, corepos_importing.model.DepartmentImporter):
|
||||
host_model_class = coreoffice.Department
|
||||
|
||||
# these fields are held in common, between Office and Lane tables
|
||||
common_fields = [
|
||||
'number',
|
||||
'name',
|
||||
'tax',
|
||||
'food_stampable',
|
||||
'limit',
|
||||
'minimum',
|
||||
'discount',
|
||||
'see_id',
|
||||
'modified',
|
||||
'modified_by_id',
|
||||
'margin',
|
||||
'sales_code',
|
||||
'member_only',
|
||||
# TODO: these seem to be newer additions?
|
||||
# 'line_item_discount',
|
||||
# 'wicable',
|
||||
]
|
||||
|
||||
@property
|
||||
def supported_fields(self):
|
||||
return self.common_fields
|
||||
|
||||
def normalize_host_object(self, department):
|
||||
data = dict([(field, getattr(department, field))
|
||||
for field in self.common_fields])
|
||||
return data
|
||||
|
||||
|
||||
class ProductImporter(FromCore, corepos_importing.model.ProductImporter):
|
||||
host_model_class = coreoffice.Product
|
||||
|
||||
|
|
Loading…
Reference in a new issue