from __future__ import unicode_literals

from django import forms
from InvenTree.forms import HelperForm

from .models import StockLocation, StockItem


class EditStockLocationForm(HelperForm):

    class Meta:
        model = StockLocation
        fields = [
            'name',
            'parent',
            'description'
        ]


class CreateStockItemForm(HelperForm):

    class Meta:
        model = StockItem
        fields = [
            'part',
            'supplier_part',
            'location',
            'belongs_to',
            'serial',
            'batch',
            'quantity',
            'status',
            # 'customer',
            'URL',
        ]


class MoveStockItemForm(forms.ModelForm):

    class Meta:
        model = StockItem

        fields = [
            'location',
        ]


class StocktakeForm(forms.ModelForm):

    class Meta:
        model = StockItem

        fields = [
            'quantity',
        ]


class EditStockItemForm(HelperForm):

    class Meta:
        model = StockItem

        fields = [
            'quantity',
            'batch',
            'status',
        ]
from __future__ import unicode_literals

from django import forms
from InvenTree.forms import HelperForm

from .models import StockLocation, StockItem


class EditStockLocationForm(HelperForm):

    class Meta:
        model = StockLocation
        fields = [
            'name',
            'parent',
            'description'
        ]


class CreateStockItemForm(HelperForm):

    class Meta:
        model = StockItem
        fields = [
            'part',
            'supplier_part',
            'location',
            'belongs_to',
            'serial',
            'batch',
            'quantity',
            'status',
            # 'customer',
            'URL',
        ]


class MoveStockItemForm(forms.ModelForm):

    class Meta:
        model = StockItem

        fields = [
            'location',
        ]


class StocktakeForm(forms.ModelForm):

    class Meta:
        model = StockItem

        fields = [
            'quantity',
        ]


class EditStockItemForm(HelperForm):

    class Meta:
        model = StockItem

        fields = [
            'batch',
            'status',
            'notes'
        ]
Update edit form for StockItem
Update edit form for StockItem

- Disallow direct quantity editing (must perform stocktake)
- Add notes field to allow editing

  from __future__ import unicode_literals
  
  from django import forms
  from InvenTree.forms import HelperForm
  
  from .models import StockLocation, StockItem
  
  
  class EditStockLocationForm(HelperForm):
  
      class Meta:
          model = StockLocation
          fields = [
              'name',
              'parent',
              'description'
          ]
  
  
  class CreateStockItemForm(HelperForm):
  
      class Meta:
          model = StockItem
          fields = [
              'part',
              'supplier_part',
              'location',
              'belongs_to',
              'serial',
              'batch',
              'quantity',
              'status',
              # 'customer',
              'URL',
          ]
  
  
  class MoveStockItemForm(forms.ModelForm):
  
      class Meta:
          model = StockItem
  
          fields = [
              'location',
          ]
  
  
  class StocktakeForm(forms.ModelForm):
  
      class Meta:
          model = StockItem
  
          fields = [
              'quantity',
          ]
  
  
  class EditStockItemForm(HelperForm):
  
      class Meta:
          model = StockItem
  
          fields = [
-             'quantity',
              'batch',
              'status',
+             'notes'
          ]
Update edit form for StockItem
## Code Before:
from __future__ import unicode_literals

from django import forms
from InvenTree.forms import HelperForm

from .models import StockLocation, StockItem


class EditStockLocationForm(HelperForm):

    class Meta:
        model = StockLocation
        fields = [
            'name',
            'parent',
            'description'
        ]


class CreateStockItemForm(HelperForm):

    class Meta:
        model = StockItem
        fields = [
            'part',
            'supplier_part',
            'location',
            'belongs_to',
            'serial',
            'batch',
            'quantity',
            'status',
            # 'customer',
            'URL',
        ]


class MoveStockItemForm(forms.ModelForm):

    class Meta:
        model = StockItem

        fields = [
            'location',
        ]


class StocktakeForm(forms.ModelForm):

    class Meta:
        model = StockItem

        fields = [
            'quantity',
        ]


class EditStockItemForm(HelperForm):

    class Meta:
        model = StockItem

        fields = [
            'quantity',
            'batch',
            'status',
        ]
## Instruction:
Update edit form for StockItem
## Code After:
from __future__ import unicode_literals

from django import forms
from InvenTree.forms import HelperForm

from .models import StockLocation, StockItem


class EditStockLocationForm(HelperForm):

    class Meta:
        model = StockLocation
        fields = [
            'name',
            'parent',
            'description'
        ]


class CreateStockItemForm(HelperForm):

    class Meta:
        model = StockItem
        fields = [
            'part',
            'supplier_part',
            'location',
            'belongs_to',
            'serial',
            'batch',
            'quantity',
            'status',
            # 'customer',
            'URL',
        ]


class MoveStockItemForm(forms.ModelForm):

    class Meta:
        model = StockItem

        fields = [
            'location',
        ]


class StocktakeForm(forms.ModelForm):

    class Meta:
        model = StockItem

        fields = [
            'quantity',
        ]


class EditStockItemForm(HelperForm):

    class Meta:
        model = StockItem

        fields = [
            'batch',
            'status',
            'notes'
        ]