2019-04-27 12:49:16 +00:00
|
|
|
"""
|
|
|
|
Django Forms for interacting with Stock app
|
|
|
|
"""
|
|
|
|
|
2018-04-17 13:13:41 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2018-04-15 10:10:49 +00:00
|
|
|
from django import forms
|
2018-04-29 14:59:36 +00:00
|
|
|
from InvenTree.forms import HelperForm
|
2018-04-15 10:10:49 +00:00
|
|
|
|
|
|
|
from .models import StockLocation, StockItem
|
|
|
|
|
2018-04-17 13:56:25 +00:00
|
|
|
|
2018-04-29 14:59:36 +00:00
|
|
|
class EditStockLocationForm(HelperForm):
|
2019-04-27 12:49:16 +00:00
|
|
|
""" Form for editing a StockLocation """
|
2018-04-15 10:10:49 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = StockLocation
|
|
|
|
fields = [
|
|
|
|
'name',
|
|
|
|
'parent',
|
|
|
|
'description'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2018-04-29 14:59:36 +00:00
|
|
|
class CreateStockItemForm(HelperForm):
|
2019-04-27 12:49:16 +00:00
|
|
|
""" Form for creating a new StockItem """
|
2018-04-15 10:10:49 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = StockItem
|
|
|
|
fields = [
|
|
|
|
'part',
|
|
|
|
'supplier_part',
|
|
|
|
'location',
|
2018-04-16 10:08:04 +00:00
|
|
|
'batch',
|
2018-04-15 10:10:49 +00:00
|
|
|
'quantity',
|
2019-05-09 13:06:19 +00:00
|
|
|
'delete_on_deplete',
|
2018-04-16 10:08:04 +00:00
|
|
|
'status',
|
2019-04-27 03:12:34 +00:00
|
|
|
'notes',
|
2018-04-16 11:07:57 +00:00
|
|
|
'URL',
|
2018-04-15 15:02:17 +00:00
|
|
|
]
|
2018-04-29 14:59:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MoveStockItemForm(forms.ModelForm):
|
2019-04-27 12:49:16 +00:00
|
|
|
""" Form for moving a StockItem to a new location """
|
2018-04-29 14:59:36 +00:00
|
|
|
|
2019-04-12 14:52:26 +00:00
|
|
|
note = forms.CharField(label='Notes', required=True, help_text='Add note (required)')
|
2019-04-12 14:08:13 +00:00
|
|
|
|
2018-04-29 14:59:36 +00:00
|
|
|
class Meta:
|
|
|
|
model = StockItem
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
'location',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2018-04-30 11:03:25 +00:00
|
|
|
class StocktakeForm(forms.ModelForm):
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = StockItem
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
'quantity',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2018-04-29 14:59:36 +00:00
|
|
|
class EditStockItemForm(HelperForm):
|
2019-05-09 08:38:37 +00:00
|
|
|
""" Form for editing a StockItem object.
|
|
|
|
Note that not all fields can be edited here (even if they can be specified during creation.
|
|
|
|
|
|
|
|
location - Must be updated in a 'move' transaction
|
|
|
|
quantity - Must be updated in a 'stocktake' transaction
|
|
|
|
part - Cannot be edited after creation
|
|
|
|
"""
|
2018-04-29 14:59:36 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = StockItem
|
|
|
|
|
|
|
|
fields = [
|
2019-04-25 13:35:48 +00:00
|
|
|
'supplier_part',
|
2018-04-29 14:59:36 +00:00
|
|
|
'batch',
|
2019-05-09 13:06:19 +00:00
|
|
|
'delete_on_deplete',
|
2018-04-29 14:59:36 +00:00
|
|
|
'status',
|
2019-04-25 13:35:48 +00:00
|
|
|
'notes',
|
|
|
|
'URL',
|
2019-04-13 23:23:24 +00:00
|
|
|
]
|