2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-02 05:26:45 +00:00

Merge pull request #1198 from SchrodingersGat/stock-item-form-fix

Fix for StockItem create / edit forms
This commit is contained in:
Oliver 2021-01-03 14:15:56 +11:00 committed by GitHub
commit bdc3a9ef02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View File

@ -1307,7 +1307,8 @@ class StockItemEdit(AjaxUpdateView):
# If the part cannot be purchased, hide the supplier_part field # If the part cannot be purchased, hide the supplier_part field
if not item.part.purchaseable: if not item.part.purchaseable:
form.fields['supplier_part'].widget = HiddenInput() form.fields['supplier_part'].widget = HiddenInput()
form.fields['purchase_price'].widget = HiddenInput()
form.fields.pop('purchase_price')
else: else:
query = form.fields['supplier_part'].queryset query = form.fields['supplier_part'].queryset
query = query.filter(part=item.part.id) query = query.filter(part=item.part.id)
@ -1522,8 +1523,8 @@ class StockItemCreate(AjaxCreateView):
form.rebuild_layout() form.rebuild_layout()
if not part.purchaseable: if not part.purchaseable:
form.fields['purchase_price'].widget = HiddenInput() form.fields.pop('purchase_price')
# Hide the 'part' field (as a valid part is selected) # Hide the 'part' field (as a valid part is selected)
# form.fields['part'].widget = HiddenInput() # form.fields['part'].widget = HiddenInput()

View File

@ -278,7 +278,7 @@ function loadStockTable(table, options) {
if (row.is_building && row.build) { if (row.is_building && row.build) {
// StockItem is currently being built! // StockItem is currently being built!
text = "{% trans "In production" %}"; text = '{% trans "In production" %}';
url = `/build/${row.build}/`; url = `/build/${row.build}/`;
} else if (row.belongs_to) { } else if (row.belongs_to) {
// StockItem is installed inside a different StockItem // StockItem is installed inside a different StockItem
@ -286,17 +286,17 @@ function loadStockTable(table, options) {
url = `/stock/item/${row.belongs_to}/installed/`; url = `/stock/item/${row.belongs_to}/installed/`;
} else if (row.customer) { } else if (row.customer) {
// StockItem has been assigned to a customer // StockItem has been assigned to a customer
text = "{% trans "Shipped to customer" %}"; text = '{% trans "Shipped to customer" %}';
url = `/company/${row.customer}/assigned-stock/`; url = `/company/${row.customer}/assigned-stock/`;
} else if (row.sales_order) { } else if (row.sales_order) {
// StockItem has been assigned to a sales order // StockItem has been assigned to a sales order
text = "{% trans "Assigned to Sales Order" %}"; text = '{% trans "Assigned to Sales Order" %}';
url = `/order/sales-order/${row.sales_order}/`; url = `/order/sales-order/${row.sales_order}/`;
} else if (row.location) { } else if (row.location) {
text = row.location_detail.pathstring; text = row.location_detail.pathstring;
url = `/stock/location/${row.location}/`; url = `/stock/location/${row.location}/`;
} else { } else {
text = "<i>{% trans "No stock location set" %}</i>"; text = '<i>{% trans "No stock location set" %}</i>';
url = ''; url = '';
} }
@ -336,7 +336,13 @@ function loadStockTable(table, options) {
return html; return html;
} }
else if (field == 'part_detail.IPN') { else if (field == 'part_detail.IPN') {
return row.part_detail.IPN; var ipn = row.part_detail.IPN;
if (ipn) {
return ipn;
} else {
return '-';
}
} }
else if (field == 'part_detail.description') { else if (field == 'part_detail.description') {
return row.part_detail.description; return row.part_detail.description;