mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 13:06:45 +00:00
Fix form validation
This commit is contained in:
parent
42a75a8238
commit
852da6d696
@ -282,7 +282,7 @@ class InstallStockForm(HelperForm):
|
|||||||
|
|
||||||
part = forms.ModelChoiceField(
|
part = forms.ModelChoiceField(
|
||||||
queryset=Part.objects.all(),
|
queryset=Part.objects.all(),
|
||||||
widget=forms.HiddenInput
|
widget=forms.HiddenInput()
|
||||||
)
|
)
|
||||||
|
|
||||||
stock_item = forms.ModelChoiceField(
|
stock_item = forms.ModelChoiceField(
|
||||||
@ -321,10 +321,10 @@ class InstallStockForm(HelperForm):
|
|||||||
|
|
||||||
print("Data:", data)
|
print("Data:", data)
|
||||||
|
|
||||||
stock_item = data['stock_item']
|
stock_item = data.get('stock_item', None)
|
||||||
quantity = data['quantity_to_install']
|
quantity = data.get('quantity_to_install', None)
|
||||||
|
|
||||||
if quantity > stock_item.quantity:
|
if stock_item and quantity and quantity > stock_item.quantity:
|
||||||
raise ValidationError({'quantity_to_install': _('Must not exceed available quantity')})
|
raise ValidationError({'quantity_to_install': _('Must not exceed available quantity')})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
@ -1079,8 +1079,6 @@ function loadInstalledInTable(table, options) {
|
|||||||
// The stock item did *not* match any items in the BOM!
|
// The stock item did *not* match any items in the BOM!
|
||||||
// Add a new row to the table...
|
// Add a new row to the table...
|
||||||
|
|
||||||
console.log("Found an unmatched part! " + item.pk + " -> " + item.part);
|
|
||||||
|
|
||||||
// Contruct a new "row" to add to the table
|
// Contruct a new "row" to add to the table
|
||||||
var new_row = {
|
var new_row = {
|
||||||
sub_part: item.part,
|
sub_part: item.part,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user