mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge branch 'master' of https://github.com/inventree/InvenTree
# Conflicts: # InvenTree/customer/templates/customer/order_index.html
This commit is contained in:
commit
cd903112cc
@ -1,18 +0,0 @@
|
||||
import inspect
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ChoiceEnum(Enum):
|
||||
""" Helper class to provide enumerated choice values for integer fields
|
||||
"""
|
||||
# http://blog.richard.do/index.php/2014/02/how-to-use-enums-for-django-field-choices/
|
||||
|
||||
@classmethod
|
||||
def choices(cls):
|
||||
# get all members of the class
|
||||
members = inspect.getmembers(cls, lambda m: not(inspect.isroutine(m)))
|
||||
# filter down to just properties
|
||||
props = [m for m in members if not(m[0][:2] == '__')]
|
||||
# format into django choice tuple
|
||||
choices = tuple([(str(p[1].value), p[0]) for p in props])
|
||||
return choices
|
@ -18,4 +18,5 @@ class BuildAdmin(admin.ModelAdmin):
|
||||
'notes',
|
||||
)
|
||||
|
||||
|
||||
admin.site.register(Build, BuildAdmin)
|
||||
|
@ -30,4 +30,4 @@ class EditBuildForm(forms.ModelForm):
|
||||
'quantity',
|
||||
'status',
|
||||
'completion_date',
|
||||
]
|
||||
]
|
||||
|
@ -8,6 +8,7 @@ from django.core.validators import MinValueValidator
|
||||
|
||||
from part.models import Part
|
||||
|
||||
|
||||
class Build(models.Model):
|
||||
""" A Build object organises the creation of new parts from the component parts
|
||||
It uses the part BOM to generate new parts.
|
||||
@ -19,26 +20,24 @@ class Build(models.Model):
|
||||
|
||||
# Build status codes
|
||||
PENDING = 10 # Build is pending / active
|
||||
HOLDING = 20 # Build is currently being held
|
||||
CANCELLED = 30 # Build was cancelled
|
||||
COMPLETE = 40 # Build is complete
|
||||
HOLDING = 20 # Build is currently being held
|
||||
CANCELLED = 30 # Build was cancelled
|
||||
COMPLETE = 40 # Build is complete
|
||||
|
||||
BUILD_STATUS_CODES = {
|
||||
PENDING : _("Pending"),
|
||||
HOLDING : _("Holding"),
|
||||
CANCELLED : _("Cancelled"),
|
||||
COMPLETE : _("Complete"),
|
||||
}
|
||||
BUILD_STATUS_CODES = {PENDING: _("Pending"),
|
||||
HOLDING: _("Holding"),
|
||||
CANCELLED: _("Cancelled"),
|
||||
COMPLETE: _("Complete"),
|
||||
}
|
||||
|
||||
batch = models.CharField(max_length=100, blank=True, null=True,
|
||||
help_text='Batch code for this build output')
|
||||
help_text='Batch code for this build output')
|
||||
|
||||
# Status of the build
|
||||
status = models.PositiveIntegerField(default=PENDING,
|
||||
choices=BUILD_STATUS_CODES.items(),
|
||||
validators=[MinValueValidator(0)])
|
||||
|
||||
|
||||
# Date the build model was 'created'
|
||||
creation_date = models.DateField(auto_now=True, editable=False)
|
||||
|
||||
|
@ -15,4 +15,4 @@ build_urls = [
|
||||
url(r'^(?P<pk>\d+)/', include(build_detail_urls)),
|
||||
|
||||
url(r'.*$', views.BuildIndex.as_view(), name='build-index'),
|
||||
]
|
||||
]
|
||||
|
@ -12,6 +12,7 @@ from .models import Build
|
||||
|
||||
from .forms import EditBuildForm
|
||||
|
||||
|
||||
class BuildIndex(ListView):
|
||||
model = Build
|
||||
template_name = 'build/index.html'
|
||||
|
@ -18,4 +18,4 @@ class CustomerOrderLineAdmin(admin.ModelAdmin):
|
||||
|
||||
admin.site.register(Customer, CustomerAdmin)
|
||||
admin.site.register(CustomerOrder, CustomerOrderAdmin)
|
||||
admin.site.register(CustomerOrderLine, CustomerOrderLineAdmin)
|
||||
admin.site.register(CustomerOrderLine, CustomerOrderLineAdmin)
|
||||
|
@ -65,7 +65,7 @@ class CustomerOrderLine(models.Model):
|
||||
# TODO: for now, each line corresponds to some quantity of some part, but in future we might want more flexibility
|
||||
# Only 'salable' items should be allowed in a CSO
|
||||
part = models.ForeignKey(Part, blank=True, help_text="Part",
|
||||
limit_choices_to={'salable' : True}
|
||||
limit_choices_to={'salable': True}
|
||||
)
|
||||
|
||||
# TODO: should quantity field here somehow related to quantity field of related part? Views will handle this, right?
|
||||
@ -73,4 +73,3 @@ class CustomerOrderLine(models.Model):
|
||||
|
||||
# Line notes
|
||||
notes = models.TextField(blank=True, help_text="Line notes")
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
from django.test import TestCase
|
||||
# from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
@ -30,4 +30,4 @@ class CustomerOrderDetail(DetailView):
|
||||
model = CustomerOrder
|
||||
template_name = 'customer/order_detail.html'
|
||||
queryset = CustomerOrder.objects.all()
|
||||
context_object_name = 'order'
|
||||
context_object_name = 'order'
|
||||
|
Loading…
Reference in New Issue
Block a user