mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
stock-item-edit is looking OK now
This commit is contained in:
parent
d357e982f5
commit
4c8bc9580c
@ -471,14 +471,10 @@ $("#stock-duplicate").click(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#stock-edit").click(function () {
|
$('#stock-edit').click(function() {
|
||||||
launchModalForm(
|
editStockItem({{ item.pk }}, {
|
||||||
"{% url 'stock-item-edit' item.id %}",
|
reload: true,
|
||||||
{
|
});
|
||||||
reload: true,
|
|
||||||
submit_text: '{% trans "Save" %}',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#stock-edit-status').click(function () {
|
$('#stock-edit-status').click(function () {
|
||||||
|
@ -105,15 +105,6 @@ class StockItemTest(StockViewTestCase):
|
|||||||
response = self.client.get(reverse('stock-item-qr', args=(9999,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
response = self.client.get(reverse('stock-item-qr', args=(9999,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_edit_item(self):
|
|
||||||
# Test edit view for StockItem
|
|
||||||
response = self.client.get(reverse('stock-item-edit', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
# Test with a non-purchaseable part
|
|
||||||
response = self.client.get(reverse('stock-item-edit', args=(100,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
def test_create_item(self):
|
def test_create_item(self):
|
||||||
"""
|
"""
|
||||||
Test creation of StockItem
|
Test creation of StockItem
|
||||||
@ -273,11 +264,15 @@ class StockOwnershipTest(StockViewTestCase):
|
|||||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||||
self.assertContains(response, '"form_valid": true', status_code=200)
|
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)
|
# Set ownership on existing item (and change location)
|
||||||
response = self.client.post(reverse('stock-item-edit', args=(test_item_id,)),
|
response = self.client.post(reverse('stock-item-edit', args=(test_item_id,)),
|
||||||
{'part': 1, 'status': StockStatus.OK, 'owner': user_as_owner.pk},
|
{'part': 1, 'status': StockStatus.OK, 'owner': user_as_owner.pk},
|
||||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||||
|
|
||||||
self.assertContains(response, '"form_valid": true', status_code=200)
|
self.assertContains(response, '"form_valid": true', status_code=200)
|
||||||
|
"""
|
||||||
|
|
||||||
# Logout
|
# Logout
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
@ -294,6 +289,8 @@ class StockOwnershipTest(StockViewTestCase):
|
|||||||
location = StockLocation.objects.get(pk=test_location_id)
|
location = StockLocation.objects.get(pk=test_location_id)
|
||||||
self.assertEqual(location.owner, user_group_owner)
|
self.assertEqual(location.owner, user_group_owner)
|
||||||
|
|
||||||
|
"""
|
||||||
|
TODO: Refactor this following test to use the new API form
|
||||||
# Test item edit
|
# Test item edit
|
||||||
response = self.client.post(reverse('stock-item-edit', args=(test_item_id,)),
|
response = self.client.post(reverse('stock-item-edit', args=(test_item_id,)),
|
||||||
{'part': 1, 'status': StockStatus.OK, 'owner': new_user_as_owner.pk},
|
{'part': 1, 'status': StockStatus.OK, 'owner': new_user_as_owner.pk},
|
||||||
@ -302,6 +299,7 @@ class StockOwnershipTest(StockViewTestCase):
|
|||||||
# Make sure the item's owner is unchanged
|
# Make sure the item's owner is unchanged
|
||||||
item = StockItem.objects.get(pk=test_item_id)
|
item = StockItem.objects.get(pk=test_item_id)
|
||||||
self.assertEqual(item.owner, user_as_owner)
|
self.assertEqual(item.owner, user_as_owner)
|
||||||
|
"""
|
||||||
|
|
||||||
# Create new parent location
|
# Create new parent location
|
||||||
parent_location = {
|
parent_location = {
|
||||||
|
@ -22,7 +22,6 @@ location_urls = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
stock_item_detail_urls = [
|
stock_item_detail_urls = [
|
||||||
url(r'^edit/', views.StockItemEdit.as_view(), name='stock-item-edit'),
|
|
||||||
url(r'^convert/', views.StockItemConvert.as_view(), name='stock-item-convert'),
|
url(r'^convert/', views.StockItemConvert.as_view(), name='stock-item-convert'),
|
||||||
url(r'^serialize/', views.StockItemSerialize.as_view(), name='stock-item-serialize'),
|
url(r'^serialize/', views.StockItemSerialize.as_view(), name='stock-item-serialize'),
|
||||||
url(r'^delete/', views.StockItemDelete.as_view(), name='stock-item-delete'),
|
url(r'^delete/', views.StockItemDelete.as_view(), name='stock-item-delete'),
|
||||||
|
@ -131,34 +131,35 @@ function editStockItem(pk, options={}) {
|
|||||||
// Prevent editing of the "part"
|
// Prevent editing of the "part"
|
||||||
fields.part.hidden = true;
|
fields.part.hidden = true;
|
||||||
|
|
||||||
var groups = stockItemGroups(options);
|
options.groups = stockItemGroups(options);
|
||||||
|
|
||||||
constructForm(url, {
|
options.fields = fields;
|
||||||
fields: fields,
|
options.title = '{% trans "Edit Stock Item" %}';
|
||||||
groups: groups,
|
|
||||||
title: '{% trans "Edit Stock Item" %}',
|
// Query parameters for retrieving stock item data
|
||||||
params: {
|
options.params = {
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
supplier_part_detail: true,
|
supplier_part_detail: true,
|
||||||
},
|
};
|
||||||
processResults: function(data, fields, options) {
|
|
||||||
// Callback when StockItem data is received from server
|
|
||||||
|
|
||||||
if (data.part_detail.trackable) {
|
// Augment the rendered form when we receive information about the StockItem
|
||||||
delete options.fields.delete_on_deplete;
|
options.processResults = function(data, fields, options) {
|
||||||
} else {
|
if (data.part_detail.trackable) {
|
||||||
// Remove serial number field if part is not trackable
|
delete options.fields.delete_on_deplete;
|
||||||
delete options.fields.serial;
|
} else {
|
||||||
}
|
// Remove serial number field if part is not trackable
|
||||||
|
delete options.fields.serial;
|
||||||
// Remove pricing fields if part is not purchaseable
|
|
||||||
if (!data.part_detail.purchaseable) {
|
|
||||||
delete options.fields.supplier_part;
|
|
||||||
delete options.fields.purchase_price;
|
|
||||||
delete options.fields.purchase_price_currency;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
// Remove pricing fields if part is not purchaseable
|
||||||
|
if (!data.part_detail.purchaseable) {
|
||||||
|
delete options.fields.supplier_part;
|
||||||
|
delete options.fields.purchase_price;
|
||||||
|
delete options.fields.purchase_price_currency;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
constructForm(url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user