Add basic support for CORE Office -> CORE Lane export
just products data so far
This commit is contained in:
parent
236ae12d20
commit
6c9d9964dc
11 changed files with 398 additions and 5 deletions
0
rattail_corepos/corepos/lane/__init__.py
Normal file
0
rattail_corepos/corepos/lane/__init__.py
Normal file
0
rattail_corepos/corepos/lane/importing/__init__.py
Normal file
0
rattail_corepos/corepos/lane/importing/__init__.py
Normal file
27
rattail_corepos/corepos/lane/importing/op/__init__.py
Normal file
27
rattail_corepos/corepos/lane/importing/op/__init__.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2021 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Importing "operational" data into CORE Lane
|
||||
"""
|
||||
|
||||
from . import model
|
42
rattail_corepos/corepos/lane/importing/op/model.py
Normal file
42
rattail_corepos/corepos/lane/importing/op/model.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2021 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
"operational" model importers for CORE Lane
|
||||
|
||||
.. warning::
|
||||
All classes in this module are "direct DB" importers, which will
|
||||
write directly to MySQL. They are meant to be used in dry-run mode
|
||||
only, and/or for sample data import to a dev system etc. They are
|
||||
*NOT* meant for production use, as they will completely bypass any
|
||||
CORE business rules logic which may exist.
|
||||
"""
|
||||
|
||||
from rattail import importing
|
||||
from rattail_corepos.corepos.common.importing import ToCore
|
||||
|
||||
from corepos.db.lane_op import model as corepos
|
||||
|
||||
|
||||
class ProductImporter(ToCore):
|
||||
model_class = corepos.Product
|
||||
key = 'id'
|
150
rattail_corepos/corepos/lane/importing/op/office.py
Normal file
150
rattail_corepos/corepos/lane/importing/op/office.py
Normal file
|
@ -0,0 +1,150 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2021 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
CORE Office -> CORE Lane import
|
||||
"""
|
||||
|
||||
from corepos.db.office_op import Session as CoreOfficeSession, model as coreoffice
|
||||
from corepos.db.lane_op import Session as CoreLaneSession
|
||||
|
||||
from rattail import importing
|
||||
from rattail.importing.handlers import FromSQLAlchemyHandler, ToSQLAlchemyHandler
|
||||
from rattail.util import OrderedDict
|
||||
from rattail_corepos.corepos.lane.importing import op as corepos_importing
|
||||
|
||||
|
||||
# TODO: this surely belongs in some other/common place? (is not lane-specific)
|
||||
class FromCoreOfficeHandler(FromSQLAlchemyHandler):
|
||||
"""
|
||||
Base class for import handlers which use CORE Office as the host.
|
||||
"""
|
||||
host_title = "CORE Office"
|
||||
|
||||
def make_host_session(self):
|
||||
return CoreOfficeSession()
|
||||
|
||||
|
||||
# TODO: this surely belongs in some other/common place? (is not office-specific)
|
||||
class ToCoreLaneHandler(ToSQLAlchemyHandler):
|
||||
"""
|
||||
Base class for import handlers which target CORE Lane on the local side.
|
||||
"""
|
||||
local_title = "CORE Lane"
|
||||
|
||||
def make_session(self):
|
||||
return CoreLaneSession()
|
||||
|
||||
|
||||
class FromCoreOfficeToCoreLane(FromCoreOfficeHandler, ToCoreLaneHandler):
|
||||
"""
|
||||
Handler for CORE Office -> CORE Lane data export.
|
||||
"""
|
||||
direction = 'export'
|
||||
|
||||
@property
|
||||
def local_title(self):
|
||||
return "CORE Lane ({})".format(self.dbkey)
|
||||
|
||||
def make_session(self):
|
||||
return CoreLaneSession(bind=self.config.core_lane_op_engines[self.dbkey])
|
||||
|
||||
def get_importers(self):
|
||||
importers = OrderedDict()
|
||||
importers['Product'] = ProductImporter
|
||||
return importers
|
||||
|
||||
|
||||
class FromCore(importing.FromSQLAlchemy):
|
||||
"""
|
||||
Base class for CORE Office -> CORE Lane data importers.
|
||||
"""
|
||||
|
||||
|
||||
class ProductImporter(FromCore, corepos_importing.model.ProductImporter):
|
||||
host_model_class = coreoffice.Product
|
||||
|
||||
# these fields are held in common, between Office and Lane tables
|
||||
common_fields = [
|
||||
'id',
|
||||
'upc',
|
||||
'description',
|
||||
'brand',
|
||||
'formatted_name',
|
||||
'normal_price',
|
||||
'price_method',
|
||||
'group_price',
|
||||
'quantity',
|
||||
'special_price',
|
||||
'special_price_method',
|
||||
'special_group_price',
|
||||
'special_quantity',
|
||||
# 'special_limit',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'department_number',
|
||||
'size',
|
||||
'tax_rate_id',
|
||||
'foodstamp',
|
||||
'scale',
|
||||
'scale_price',
|
||||
'mix_match_code',
|
||||
# 'created',
|
||||
# 'modified',
|
||||
|
||||
# TODO: what to do about this 'replaces' thing?
|
||||
# 'batchID'=>array('type'=>'TINYINT', 'replaces'=>'advertised'),
|
||||
# batch_id = sa.Column('batchID', sa.SmallInteger(), nullable=True)
|
||||
# advertised = sa.Column(sa.Boolean(), nullable=True)
|
||||
|
||||
'tare_weight',
|
||||
'discount',
|
||||
'discount_type',
|
||||
'line_item_discountable',
|
||||
'unit_of_measure',
|
||||
'wicable',
|
||||
'quantity_enforced',
|
||||
'id_enforced',
|
||||
'cost',
|
||||
# 'special_cost',
|
||||
# 'received_cost',
|
||||
'in_use',
|
||||
'flags',
|
||||
'subdepartment_number',
|
||||
'deposit',
|
||||
'local',
|
||||
'store_id',
|
||||
'default_vendor_id',
|
||||
'current_origin_id',
|
||||
# 'auto_par',
|
||||
# 'price_rule_id',
|
||||
'last_sold',
|
||||
]
|
||||
|
||||
@property
|
||||
def supported_fields(self):
|
||||
return self.common_fields
|
||||
|
||||
def normalize_host_object(self, product):
|
||||
data = dict([(field, getattr(product, field))
|
||||
for field in self.common_fields])
|
||||
return data
|
Loading…
Add table
Add a link
Reference in a new issue