Fix datasync bug for CORE API -> Rattail
This commit is contained in:
		
							parent
							
								
									82ad5ad441
								
							
						
					
					
						commit
						7eb7c25172
					
				
					 3 changed files with 59 additions and 43 deletions
				
			
		|  | @ -2,7 +2,7 @@ | |||
| ################################################################################ | ||||
| # | ||||
| #  Rattail -- Retail Software Framework | ||||
| #  Copyright © 2010-2021 Lance Edgar | ||||
| #  Copyright © 2010-2022 Lance Edgar | ||||
| # | ||||
| #  This file is part of Rattail. | ||||
| # | ||||
|  | @ -24,7 +24,7 @@ | |||
| DataSync for Rattail DB | ||||
| """ | ||||
| 
 | ||||
| from sqlalchemy.orm.exc import NoResultFound | ||||
| from sqlalchemy import orm | ||||
| 
 | ||||
| from corepos.db.office_op import Session as CoreSession, model as corepos | ||||
| 
 | ||||
|  | @ -48,15 +48,18 @@ class FromCOREAPIToRattail(DataSyncImportConsumer): | |||
|     def establish_api(self): | ||||
|         self.api = make_corepos_api(self.config) | ||||
| 
 | ||||
|     def process_changes(self, session, changes): | ||||
|     def pre_process_changes(self, session, changes): | ||||
| 
 | ||||
|         # declare user responsible | ||||
|         if self.runas_username: | ||||
|             session.set_continuum_user(self.runas_username) | ||||
| 
 | ||||
|         # update all importers with current Rattail session | ||||
|         for importer in self.importers.values(): | ||||
|             importer.session = session | ||||
|             # also establish the API client for each! | ||||
|             importer.establish_api() | ||||
|             importer.datasync_setup() | ||||
| 
 | ||||
|     def process_changes_proper(self, session, changes): | ||||
| 
 | ||||
|         # sync all Customer-related changes | ||||
|         types = [ | ||||
|  | @ -176,7 +179,7 @@ class FromCOREPOSToRattailProducts(FromCOREPOSToRattailBase): | |||
|                 return self.corepos_session.query(corepos.Product)\ | ||||
|                                            .filter(corepos.Product.upc == change.payload_key)\ | ||||
|                                            .one() | ||||
|             except NoResultFound: | ||||
|             except orm.exc.NoResultFound: | ||||
|                 pass | ||||
| 
 | ||||
|         else: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar