mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Fixes for unit tests
This commit is contained in:
		| @@ -121,12 +121,17 @@ class StockAdjust(APIView): | ||||
|     - StockAdd: add stock items | ||||
|     - StockRemove: remove stock items | ||||
|     - StockTransfer: transfer stock items | ||||
|  | ||||
|     # TODO - This needs serious refactoring!!! | ||||
|  | ||||
|     """ | ||||
|  | ||||
|     permission_classes = [ | ||||
|         permissions.IsAuthenticated, | ||||
|     ] | ||||
|  | ||||
|     allow_missing_quantity = False | ||||
|  | ||||
|     def get_items(self, request): | ||||
|         """ | ||||
|         Return a list of items posted to the endpoint. | ||||
| @@ -157,11 +162,13 @@ class StockAdjust(APIView): | ||||
|             except (ValueError, StockItem.DoesNotExist): | ||||
|                 raise ValidationError({'pk': 'Each entry must contain a valid pk field'}) | ||||
|  | ||||
|             if self.allow_missing_quantity and 'quantity' not in entry: | ||||
|                 entry['quantity'] = item.quantity | ||||
|  | ||||
|             try: | ||||
|                 quantity = Decimal(str(entry.get('quantity', None))) | ||||
|             except (ValueError, TypeError, InvalidOperation): | ||||
|                 # Default to the quantity of the item | ||||
|                 quantity = item.quantity | ||||
|                 raise ValidationError({'quantity': "Each entry must contain a valid quantity value"}) | ||||
|  | ||||
|             if quantity < 0: | ||||
|                 raise ValidationError({'quantity': 'Quantity field must not be less than zero'}) | ||||
| @@ -235,6 +242,8 @@ class StockTransfer(StockAdjust): | ||||
|     API endpoint for performing stock movements | ||||
|     """ | ||||
|  | ||||
|     allow_missing_quantity = True | ||||
|  | ||||
|     def post(self, request, *args, **kwargs): | ||||
|  | ||||
|         self.get_items(request) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user