Add shared GPC search filter, use it for product batch rows.
This commit is contained in:
		
							parent
							
								
									51e4eda662
								
							
						
					
					
						commit
						69a5eed83b
					
				
					 5 changed files with 41 additions and 34 deletions
				
			
		|  | @ -123,32 +123,9 @@ class ProductsGrid(SearchableAlchemyGridView): | |||
|             } | ||||
| 
 | ||||
|     def filter_map(self): | ||||
| 
 | ||||
|         def filter_upc(): | ||||
| 
 | ||||
|             def filter_is(q, v): | ||||
|                 if not v: | ||||
|                     return q | ||||
|                 try: | ||||
|                     return q.filter(Product.upc.in_(( | ||||
|                                 GPC(v), GPC(v, calc_check_digit='upc')))) | ||||
|                 except ValueError: | ||||
|                     return q | ||||
| 
 | ||||
|             def filter_not(q, v): | ||||
|                 if not v: | ||||
|                     return q | ||||
|                 try: | ||||
|                     return q.filter(~Product.upc.in_(( | ||||
|                                 GPC(v), GPC(v, calc_check_digit='upc')))) | ||||
|                 except ValueError: | ||||
|                     return q | ||||
| 
 | ||||
|             return {'is': filter_is, 'nt': filter_not} | ||||
| 
 | ||||
|         return self.make_filter_map( | ||||
|             ilike=['description', 'size'], | ||||
|             upc=filter_upc(), | ||||
|             upc=self.filter_gpc(model.Product.upc), | ||||
|             brand=self.filter_ilike(Brand.name), | ||||
|             family=self.filter_ilike(model.Family.name), | ||||
|             department=self.filter_ilike(Department.name), | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar