mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
StockLocationEdit
This commit is contained in:
parent
4c8bc9580c
commit
0d9c08b49c
@ -243,12 +243,11 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
{% if location %}
|
{% if location %}
|
||||||
|
|
||||||
$('#location-edit').click(function() {
|
$('#location-edit').click(function() {
|
||||||
launchModalForm("{% url 'stock-location-edit' location.id %}",
|
editStockLocation({{ location.id }}, {
|
||||||
{
|
reload: true,
|
||||||
reload: true
|
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#location-delete').click(function() {
|
$('#location-delete').click(function() {
|
||||||
|
@ -66,10 +66,6 @@ class StockListTest(StockViewTestCase):
|
|||||||
class StockLocationTest(StockViewTestCase):
|
class StockLocationTest(StockViewTestCase):
|
||||||
""" Tests for StockLocation views """
|
""" 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):
|
def test_qr_code(self):
|
||||||
# Request the StockLocation QR view
|
# Request the StockLocation QR view
|
||||||
response = self.client.get(reverse('stock-location-qr', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
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
|
# Enable ownership control
|
||||||
self.enable_ownership()
|
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
|
TODO: Refactor this following test to use the new API form
|
||||||
# Set ownership on existing item (and change location)
|
# Set ownership on existing item (and change location)
|
||||||
@ -280,15 +270,6 @@ class StockOwnershipTest(StockViewTestCase):
|
|||||||
# Login with new user
|
# Login with new user
|
||||||
self.client.login(username='john', password='custom123')
|
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
|
TODO: Refactor this following test to use the new API form
|
||||||
# Test item edit
|
# Test item edit
|
||||||
@ -370,16 +351,3 @@ class StockOwnershipTest(StockViewTestCase):
|
|||||||
|
|
||||||
# Logout
|
# Logout
|
||||||
self.client.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'^new/', views.StockLocationCreate.as_view(), name='stock-location-create'),
|
||||||
|
|
||||||
url(r'^(?P<pk>\d+)/', include([
|
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'^delete/?', views.StockLocationDelete.as_view(), name='stock-location-delete'),
|
||||||
url(r'^qr_code/?', views.StockLocationQRCode.as_view(), name='stock-location-qr'),
|
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.
|
View for editing details of a StockLocation.
|
||||||
This view is used with the EditStockLocationForm to deliver a modal form to the web view
|
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
|
model = StockLocation
|
||||||
|
@ -51,13 +51,14 @@
|
|||||||
loadStockTestResultsTable,
|
loadStockTestResultsTable,
|
||||||
loadStockTrackingTable,
|
loadStockTrackingTable,
|
||||||
loadTableFilters,
|
loadTableFilters,
|
||||||
locationFields,
|
|
||||||
removeStockRow,
|
removeStockRow,
|
||||||
|
stockItemFields,
|
||||||
|
stockLocationFields,
|
||||||
stockStatusCodes,
|
stockStatusCodes,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function locationFields() {
|
function stockLocationFields(options={}) {
|
||||||
return {
|
return {
|
||||||
parent: {
|
parent: {
|
||||||
help_text: '{% trans "Parent stock location" %}',
|
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={}) {
|
function stockItemFields(options={}) {
|
||||||
var fields = {
|
var fields = {
|
||||||
part: {},
|
part: {},
|
||||||
|
Loading…
Reference in New Issue
Block a user