Warn if user "scans" UPC with more than 14 digits, for mobile inventory
never assume such a UPC is valid, warn instead of adding batch row
This commit is contained in:
		
							parent
							
								
									07e7c5c4a0
								
							
						
					
					
						commit
						dd7c2a0763
					
				
					 1 changed files with 19 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -235,6 +235,8 @@ class InventoryBatchView(BatchMasterView):
 | 
			
		|||
        upc = re.sub(r'\D', '', upc)
 | 
			
		||||
        if upc:
 | 
			
		||||
 | 
			
		||||
            if len(upc) <= 14:
 | 
			
		||||
 | 
			
		||||
                # try to locate general product by UPC; add to batch either way
 | 
			
		||||
                provided = GPC(upc, calc_check_digit=False)
 | 
			
		||||
                checked = GPC(upc, calc_check_digit='upc')
 | 
			
		||||
| 
						 | 
				
			
			@ -250,6 +252,10 @@ class InventoryBatchView(BatchMasterView):
 | 
			
		|||
                    row.description = "(unknown product)"
 | 
			
		||||
                self.handler.add_row(batch, row)
 | 
			
		||||
 | 
			
		||||
            else:
 | 
			
		||||
                self.request.session.flash("UPC has too many digits ({}): {}".format(len(upc), upc), 'error')
 | 
			
		||||
                return self.redirect(self.get_action_url('view', batch, mobile=True))
 | 
			
		||||
 | 
			
		||||
        self.Session.flush()
 | 
			
		||||
        return self.redirect(self.mobile_row_route_url('view', uuid=row.batch_uuid, row_uuid=row.uuid))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue