Changeset - 980c2fa952f2
[Not reviewed]
0 2 0
Lance Edgar - 3 years ago 2021-08-31 22:41:32
lance@edbob.org
Add CORE Office -> Lane op importer for Department
2 files changed with 39 insertions and 0 deletions:
0 comments (0 inline, 0 general) First comment
rattail_corepos/corepos/lane/importing/op/model.py
Show inline comments
 
@@ -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'
rattail_corepos/corepos/lane/importing/op/office.py
Show inline comments
 
@@ -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
 

	
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now