Cleanup refresh logic a bit, for vendor invoice batches
This commit is contained in:
		
							parent
							
								
									d96d22ab68
								
							
						
					
					
						commit
						76da7e7193
					
				
					 1 changed files with 21 additions and 21 deletions
				
			
		|  | @ -108,29 +108,29 @@ class VendorInvoiceHandler(BatchHandler): | |||
|         """ | ||||
|         Attempt to locate the product for the row, based on UPC etc. | ||||
|         """ | ||||
|         session = orm.object_session(row) | ||||
| 
 | ||||
|         if row.upc: | ||||
|             product = self.find_product_by_upc(session, row.upc) | ||||
|             if product: | ||||
|                 return product | ||||
| 
 | ||||
|         if row.vendor_code: | ||||
|             product = self.find_product_by_vendor_code(session, row.vendor_code) | ||||
|             if product: | ||||
|                 return product | ||||
| 
 | ||||
|     def find_product_by_upc(self, session, upc): | ||||
|         if hasattr(self, 'products'): | ||||
|             return self.products['upc'].get(upc) | ||||
|         else: | ||||
|             return api.get_product_by_upc(session, upc) | ||||
| 
 | ||||
|             if row.upc: | ||||
|                 product = self.products['upc'].get(row.upc) | ||||
|                 if product: | ||||
|                     return product | ||||
| 
 | ||||
|             if row.vendor_code: | ||||
|                 product = self.products['vendor_code'].get(row.vendor_code) | ||||
|                 if product: | ||||
|                     return product | ||||
| 
 | ||||
|         else: # no cache, must query | ||||
| 
 | ||||
|             session = orm.object_session(row) | ||||
| 
 | ||||
|             if row.upc: | ||||
|                 product = api.get_product_by_upc(session, row.upc) | ||||
|                 if product: | ||||
|                     return product | ||||
| 
 | ||||
|             if row.vendor_code: | ||||
|                 product = api.get_product_by_vendor_code(session, row.vendor_code, self.vendor) | ||||
|     def find_product_by_vendor_code(self, session, code): | ||||
|         if hasattr(self, 'products'): | ||||
|             return self.products['vendor_code'].get(code) | ||||
|         else: | ||||
|             return api.get_product_by_upc(session, code, self.vendor) | ||||
| 
 | ||||
|     def refresh_row(self, row): | ||||
|         """ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar