mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	StockLocationEdit
This commit is contained in:
		| @@ -243,12 +243,11 @@ | ||||
|     }); | ||||
|  | ||||
|     {% if location %} | ||||
|  | ||||
|     $('#location-edit').click(function() { | ||||
|         launchModalForm("{% url 'stock-location-edit' location.id %}", | ||||
|                         { | ||||
|                             reload: true | ||||
|         editStockLocation({{ location.id }}, { | ||||
|             reload: true, | ||||
|         }); | ||||
|         return false; | ||||
|     }); | ||||
|  | ||||
|     $('#location-delete').click(function() { | ||||
|   | ||||
| @@ -66,10 +66,6 @@ class StockListTest(StockViewTestCase): | ||||
| class StockLocationTest(StockViewTestCase): | ||||
|     """ Tests for StockLocation views """ | ||||
|  | ||||
|     def test_location_edit(self): | ||||
|         response = self.client.get(reverse('stock-location-edit', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest') | ||||
|         self.assertEqual(response.status_code, 200) | ||||
|  | ||||
|     def test_qr_code(self): | ||||
|         # Request the StockLocation QR view | ||||
|         response = self.client.get(reverse('stock-location-qr', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest') | ||||
| @@ -258,12 +254,6 @@ class StockOwnershipTest(StockViewTestCase): | ||||
|         # Enable ownership control | ||||
|         self.enable_ownership() | ||||
|  | ||||
|         # Set ownership on existing location | ||||
|         response = self.client.post(reverse('stock-location-edit', args=(test_location_id,)), | ||||
|                                     {'name': 'Office', 'owner': user_group_owner.pk}, | ||||
|                                     HTTP_X_REQUESTED_WITH='XMLHttpRequest') | ||||
|         self.assertContains(response, '"form_valid": true', status_code=200) | ||||
|  | ||||
|         """ | ||||
|         TODO: Refactor this following test to use the new API form | ||||
|         # Set ownership on existing item (and change location) | ||||
| @@ -280,15 +270,6 @@ class StockOwnershipTest(StockViewTestCase): | ||||
|         # Login with new user | ||||
|         self.client.login(username='john', password='custom123') | ||||
|  | ||||
|         # Test location edit | ||||
|         response = self.client.post(reverse('stock-location-edit', args=(test_location_id,)), | ||||
|                                     {'name': 'Office', 'owner': new_user_group_owner.pk}, | ||||
|                                     HTTP_X_REQUESTED_WITH='XMLHttpRequest') | ||||
|  | ||||
|         # Make sure the location's owner is unchanged | ||||
|         location = StockLocation.objects.get(pk=test_location_id) | ||||
|         self.assertEqual(location.owner, user_group_owner) | ||||
|  | ||||
|         """ | ||||
|         TODO: Refactor this following test to use the new API form | ||||
|         # Test item edit | ||||
| @@ -370,16 +351,3 @@ class StockOwnershipTest(StockViewTestCase): | ||||
|  | ||||
|         # Logout | ||||
|         self.client.logout() | ||||
|  | ||||
|         # Login with admin | ||||
|         self.client.login(username='username', password='password') | ||||
|  | ||||
|         # Switch owner of location | ||||
|         response = self.client.post(reverse('stock-location-edit', args=(location_created.pk,)), | ||||
|                                     {'name': new_location['name'], 'owner': user_group_owner.pk}, | ||||
|                                     HTTP_X_REQUESTED_WITH='XMLHttpRequest') | ||||
|         self.assertContains(response, '"form_valid": true', status_code=200) | ||||
|  | ||||
|         # Check that owner was updated for item in this location | ||||
|         stock_item = StockItem.objects.all().last() | ||||
|         self.assertEqual(stock_item.owner, user_group_owner) | ||||
|   | ||||
| @@ -11,7 +11,6 @@ location_urls = [ | ||||
|     url(r'^new/', views.StockLocationCreate.as_view(), name='stock-location-create'), | ||||
|  | ||||
|     url(r'^(?P<pk>\d+)/', include([ | ||||
|         url(r'^edit/?', views.StockLocationEdit.as_view(), name='stock-location-edit'), | ||||
|         url(r'^delete/?', views.StockLocationDelete.as_view(), name='stock-location-delete'), | ||||
|         url(r'^qr_code/?', views.StockLocationQRCode.as_view(), name='stock-location-qr'), | ||||
|          | ||||
|   | ||||
| @@ -149,6 +149,10 @@ class StockLocationEdit(AjaxUpdateView): | ||||
|     """ | ||||
|     View for editing details of a StockLocation. | ||||
|     This view is used with the EditStockLocationForm to deliver a modal form to the web view | ||||
|  | ||||
|     TODO: Remove this code as location editing has been migrated to the API forms | ||||
|           - Have to still validate that all form functionality (as below) as been ported | ||||
|  | ||||
|     """ | ||||
|  | ||||
|     model = StockLocation | ||||
|   | ||||
| @@ -51,13 +51,14 @@ | ||||
|     loadStockTestResultsTable, | ||||
|     loadStockTrackingTable, | ||||
|     loadTableFilters, | ||||
|     locationFields, | ||||
|     removeStockRow, | ||||
|     stockItemFields, | ||||
|     stockLocationFields, | ||||
|     stockStatusCodes, | ||||
| */ | ||||
|  | ||||
|  | ||||
| function locationFields() { | ||||
| function stockLocationFields(options={}) { | ||||
|     return { | ||||
|         parent: { | ||||
|             help_text: '{% trans "Parent stock location" %}', | ||||
| @@ -68,6 +69,19 @@ function locationFields() { | ||||
| } | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * Launch an API form to edit a stock location | ||||
|  */ | ||||
| function editStockLocation(pk, options={}) { | ||||
|  | ||||
|     var url = `/api/stock/location/${pk}/`; | ||||
|  | ||||
|     options.fields = stockLocationFields(options); | ||||
|  | ||||
|     constructForm(url, options); | ||||
| } | ||||
|  | ||||
|  | ||||
| function stockItemFields(options={}) { | ||||
|     var fields = { | ||||
|         part: {}, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user