diff --git a/rattail_corepos/corepos/lane/importing/op/model.py b/rattail_corepos/corepos/lane/importing/op/model.py index e9f4163..dbb48f0 100644 --- a/rattail_corepos/corepos/lane/importing/op/model.py +++ b/rattail_corepos/corepos/lane/importing/op/model.py @@ -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' diff --git a/rattail_corepos/corepos/lane/importing/op/office.py b/rattail_corepos/corepos/lane/importing/op/office.py index 9e96e99..2071ca4 100644 --- a/rattail_corepos/corepos/lane/importing/op/office.py +++ b/rattail_corepos/corepos/lane/importing/op/office.py @@ -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