Changeset - 9b00de26c671
[Not reviewed]
0 1 0
Lance Edgar - 4 years ago 2021-01-27 10:12:46
lance@edbob.org
Be sure to update Rattail Product, when VendorItem changes in CORE

b/c of the `Product.case_size` field
1 file changed with 30 insertions and 2 deletions:
0 comments (0 inline, 0 general) First comment
rattail_corepos/datasync/rattail.py
Show inline comments
 
@@ -79,16 +79,34 @@ class FromCOREAPIToRattail(NewDataSyncImportConsumer):
 
                self.process_change(session, self.importers['Member'],
 
                                    host_object=member)
 

	
 
        # process all remaining supported models with typical logic
 
        # sync all "product meta" changes
 
        types = [
 
            'Department',
 
            'Subdepartment',
 
            'Vendor',
 
        ]
 
        for change in [c for c in changes if c.payload_type in types]:
 
            # normal logic works fine here
 
            self.invoke_importer(session, change)
 

	
 
        # sync all Product-related changes
 
        types = [
 
            'Product',
 
            'VendorItem',
 
        ]
 
        for change in [c for c in changes if c.payload_type in types]:
 
            self.invoke_importer(session, change)
 

	
 
            # process deletion per usual logic
 
            if change.deletion:
 
                self.invoke_importer(session, change)
 
                if change.payload_type == 'Product':
 
                    continue # stop here if we just deleted a Product
 

	
 
            # try to process change for Product
 
            product = self.get_product(change)
 
            if product:
 
                self.process_change(session, self.importers['Product'],
 
                                    host_object=product)
 

	
 
    def get_host_object(self, session, change):
 
        if change.payload_type == 'Member':
 
@@ -108,6 +126,16 @@ class FromCOREAPIToRattail(NewDataSyncImportConsumer):
 
                if vendorID.isdigit():
 
                    return self.api.get_vendor_item(upc, int(vendorID))
 

	
 
    def get_product(self, change):
 
        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 upc:
 
                    return self.api.get_product(upc)
 

	
 

	
 
class FromCOREPOSToRattailBase(NewDataSyncImportConsumer):
 
    """
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now