Add datasync support for CORE VendorItem -> ProductCost
This commit is contained in:
parent
580f2093ae
commit
aff04035ff
|
@ -37,6 +37,9 @@ class FromCOREAPIToRattail(NewDataSyncImportConsumer):
|
|||
Consumer for CORE POS (API) -> Rattail datasync
|
||||
"""
|
||||
handler_spec = 'rattail_corepos.importing.corepos.api:FromCOREPOSToRattail'
|
||||
model_map = {
|
||||
'VendorItem': 'ProductCost',
|
||||
}
|
||||
|
||||
def setup(self):
|
||||
super(FromCOREAPIToRattail, self).setup()
|
||||
|
@ -82,6 +85,7 @@ class FromCOREAPIToRattail(NewDataSyncImportConsumer):
|
|||
'Subdepartment',
|
||||
'Vendor',
|
||||
'Product',
|
||||
'VendorItem',
|
||||
]
|
||||
for change in [c for c in changes if c.payload_type in types]:
|
||||
self.invoke_importer(session, change)
|
||||
|
@ -97,6 +101,12 @@ class FromCOREAPIToRattail(NewDataSyncImportConsumer):
|
|||
return self.api.get_vendor(change.payload_key)
|
||||
if change.payload_type == 'Product':
|
||||
return self.api.get_product(change.payload_key)
|
||||
if change.payload_type == 'VendorItem':
|
||||
fields = change.payload_key.split('|')
|
||||
if len(fields) == 2:
|
||||
upc, vendorID = fields
|
||||
if vendorID.isdigit():
|
||||
return self.api.get_vendor_item(upc, int(vendorID))
|
||||
|
||||
|
||||
class FromCOREPOSToRattailBase(NewDataSyncImportConsumer):
|
||||
|
|
|
@ -614,6 +614,7 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp
|
|||
if hasattr(self, 'vendors'):
|
||||
return self.vendors.get(corepos_id)
|
||||
|
||||
model = self.config.get_model()
|
||||
try:
|
||||
return self.session.query(model.Vendor)\
|
||||
.join(model.CoreVendor)\
|
||||
|
@ -626,7 +627,7 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp
|
|||
if hasattr(self, 'corepos_products'):
|
||||
return self.corepos_products.get(item['upc'])
|
||||
|
||||
return self.api.get_vendor_item(item['upc'], item['vendorID'])
|
||||
return self.api.get_product(item['upc'])
|
||||
|
||||
def normalize_host_object(self, item):
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue