diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py index 10e1aeac0c..2a4e15d3c6 100644 --- a/InvenTree/stock/forms.py +++ b/InvenTree/stock/forms.py @@ -67,7 +67,7 @@ class MoveMultipleStockItemsForm(forms.ModelForm): return choices - location = forms.ChoiceField(label='Destination', required=True, help_text='Destination stock location') + destination = forms.ChoiceField(label='Destination', required=True, help_text='Destination stock location') note = forms.CharField(label='Notes', required=True, help_text='Add note (required)') # transaction = forms.BooleanField(required=False, initial=False, label='Create Transaction', help_text='Create a stock transaction for these parts') confirm = forms.BooleanField(required=False, initial=False, label='Confirm Stock Movement', help_text='Confirm movement of stock items') @@ -75,13 +75,13 @@ class MoveMultipleStockItemsForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields['location'].choices = self.get_location_choices() + self.fields['destination'].choices = self.get_location_choices() class Meta: model = StockItem fields = [ - 'location', + 'destination', 'note', # 'transaction', 'confirm', diff --git a/InvenTree/stock/templates/stock/stock_move.html b/InvenTree/stock/templates/stock/stock_move.html index 427ff2f058..6a35701557 100644 --- a/InvenTree/stock/templates/stock/stock_move.html +++ b/InvenTree/stock/templates/stock/stock_move.html @@ -20,6 +20,9 @@ {{ item.location.pathstring }} + {% if item.error %} +
{{ item.error }} + {% endif %} diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 60b0f3ab47..6101a4dce9 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -10,6 +10,8 @@ from django.views.generic import DetailView, ListView from django.forms.models import model_to_dict from django.forms import HiddenInput +from django.utils.translation import ugettext as _ + from InvenTree.views import AjaxView from InvenTree.views import AjaxUpdateView, AjaxDeleteView, AjaxCreateView from InvenTree.views import QRCodeView @@ -229,7 +231,17 @@ class StockItemMoveMultiple(AjaxView, FormMixin): try: q = int(item.new_quantity) except ValueError: - item.error = 'Must enter integer value' + item.error = _('Must enter integer value') + valid = False + continue + + if q < 0: + item.error = _('Quantity must be positive') + valid = False + continue + + if q > item.quantity: + item.error = _('Quantity must not exceed {x}'.format(x=item.quantity)) valid = False continue @@ -237,7 +249,7 @@ class StockItemMoveMultiple(AjaxView, FormMixin): if not confirmed: valid = False - form.errors['confirm'] = ['Confirm stock adjustment'] + form.errors['confirm'] = [_('Confirm stock adjustment')] data = { 'form_valid': False,