2019-06-05 10:59:30 +00:00
|
|
|
"""
|
|
|
|
Django Forms for interacting with Order objects
|
|
|
|
"""
|
|
|
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2019-06-10 12:14:23 +00:00
|
|
|
from django import forms
|
2019-09-20 01:52:38 +00:00
|
|
|
from django.utils.translation import ugettext as _
|
2019-06-10 12:14:23 +00:00
|
|
|
|
2019-09-23 09:02:36 +00:00
|
|
|
from mptt.fields import TreeNodeChoiceField
|
|
|
|
|
2019-06-05 10:59:30 +00:00
|
|
|
from InvenTree.forms import HelperForm
|
2020-03-31 10:23:57 +00:00
|
|
|
from InvenTree.fields import RoundingDecimalFormField
|
2019-06-05 10:59:30 +00:00
|
|
|
|
2019-09-23 09:02:36 +00:00
|
|
|
from stock.models import StockLocation
|
2020-03-22 07:41:41 +00:00
|
|
|
from .models import PurchaseOrder, PurchaseOrderLineItem, PurchaseOrderAttachment
|
2020-04-20 23:42:11 +00:00
|
|
|
from .models import SalesOrder, SalesOrderLineItem, SalesOrderAttachment
|
2019-06-05 12:24:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class IssuePurchaseOrderForm(HelperForm):
|
|
|
|
|
2019-09-20 01:52:38 +00:00
|
|
|
confirm = forms.BooleanField(required=False, help_text=_('Place order'))
|
2019-06-10 12:14:23 +00:00
|
|
|
|
2019-06-05 12:24:18 +00:00
|
|
|
class Meta:
|
|
|
|
model = PurchaseOrder
|
|
|
|
fields = [
|
2019-06-10 12:14:23 +00:00
|
|
|
'confirm',
|
2019-06-05 12:24:18 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-12-04 23:29:16 +00:00
|
|
|
class CompletePurchaseOrderForm(HelperForm):
|
|
|
|
|
|
|
|
confirm = forms.BooleanField(required=False, help_text=_("Mark order as complete"))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PurchaseOrder
|
|
|
|
fields = [
|
|
|
|
'confirm',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-09-20 01:52:38 +00:00
|
|
|
class CancelPurchaseOrderForm(HelperForm):
|
|
|
|
|
|
|
|
confirm = forms.BooleanField(required=False, help_text=_('Cancel order'))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PurchaseOrder
|
|
|
|
fields = [
|
|
|
|
'confirm',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-09-23 09:02:36 +00:00
|
|
|
class ReceivePurchaseOrderForm(HelperForm):
|
|
|
|
|
|
|
|
location = TreeNodeChoiceField(queryset=StockLocation.objects.all(), required=True, help_text=_('Receive parts to this location'))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PurchaseOrder
|
|
|
|
fields = [
|
|
|
|
'location',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-06-05 12:24:18 +00:00
|
|
|
class EditPurchaseOrderForm(HelperForm):
|
|
|
|
""" Form for editing a PurchaseOrder object """
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PurchaseOrder
|
|
|
|
fields = [
|
|
|
|
'reference',
|
|
|
|
'supplier',
|
2020-04-15 04:24:59 +00:00
|
|
|
'supplier_reference',
|
2019-06-05 12:24:18 +00:00
|
|
|
'description',
|
2020-04-06 01:56:52 +00:00
|
|
|
'link',
|
2019-06-05 12:24:18 +00:00
|
|
|
]
|
2019-06-05 10:59:30 +00:00
|
|
|
|
|
|
|
|
2020-04-20 12:13:07 +00:00
|
|
|
class EditSalesOrderForm(HelperForm):
|
|
|
|
""" Form for editing a SalesOrder object """
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SalesOrder
|
|
|
|
fields = [
|
|
|
|
'reference',
|
|
|
|
'customer',
|
|
|
|
'customer_reference',
|
|
|
|
'description',
|
|
|
|
'link'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2020-03-22 07:41:41 +00:00
|
|
|
class EditPurchaseOrderAttachmentForm(HelperForm):
|
|
|
|
""" Form for editing a PurchaseOrderAttachment object """
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PurchaseOrderAttachment
|
|
|
|
fields = [
|
|
|
|
'order',
|
|
|
|
'attachment',
|
|
|
|
'comment'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2020-04-20 23:42:11 +00:00
|
|
|
class EditSalesOrderAttachmentForm(HelperForm):
|
|
|
|
""" Form for editing a SalesOrderAttachment object """
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SalesOrderAttachment
|
|
|
|
fields = [
|
|
|
|
'order',
|
|
|
|
'attachment',
|
|
|
|
'comment'
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-06-05 10:59:30 +00:00
|
|
|
class EditPurchaseOrderLineItemForm(HelperForm):
|
2019-06-05 12:24:18 +00:00
|
|
|
""" Form for editing a PurchaseOrderLineItem object """
|
2019-06-05 10:59:30 +00:00
|
|
|
|
2020-03-31 10:23:57 +00:00
|
|
|
quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5)
|
|
|
|
|
2019-06-05 10:59:30 +00:00
|
|
|
class Meta:
|
|
|
|
model = PurchaseOrderLineItem
|
|
|
|
fields = [
|
|
|
|
'order',
|
|
|
|
'part',
|
|
|
|
'quantity',
|
|
|
|
'reference',
|
2019-06-13 11:57:35 +00:00
|
|
|
'notes',
|
2019-06-05 11:56:52 +00:00
|
|
|
]
|
2020-04-20 23:02:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EditSalesOrderLineItemForm(HelperForm):
|
|
|
|
""" Form for editing a SalesOrderLineItem object """
|
|
|
|
|
|
|
|
quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SalesOrderLineItem
|
|
|
|
fields = [
|
|
|
|
'order',
|
|
|
|
'part',
|
|
|
|
'quantity',
|
|
|
|
'reference',
|
|
|
|
'notes'
|
|
|
|
]
|