2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00
# Conflicts:
#	InvenTree/customer/templates/customer/order_index.html
This commit is contained in:
James Newlands 2018-04-18 00:39:15 +10:00
commit cd903112cc
10 changed files with 18 additions and 36 deletions

View File

@ -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

View File

@ -18,4 +18,5 @@ class BuildAdmin(admin.ModelAdmin):
'notes', 'notes',
) )
admin.site.register(Build, BuildAdmin) admin.site.register(Build, BuildAdmin)

View File

@ -30,4 +30,4 @@ class EditBuildForm(forms.ModelForm):
'quantity', 'quantity',
'status', 'status',
'completion_date', 'completion_date',
] ]

View File

@ -8,6 +8,7 @@ from django.core.validators import MinValueValidator
from part.models import Part from part.models import Part
class Build(models.Model): class Build(models.Model):
""" A Build object organises the creation of new parts from the component parts """ A Build object organises the creation of new parts from the component parts
It uses the part BOM to generate new parts. It uses the part BOM to generate new parts.
@ -19,26 +20,24 @@ class Build(models.Model):
# Build status codes # Build status codes
PENDING = 10 # Build is pending / active PENDING = 10 # Build is pending / active
HOLDING = 20 # Build is currently being held HOLDING = 20 # Build is currently being held
CANCELLED = 30 # Build was cancelled CANCELLED = 30 # Build was cancelled
COMPLETE = 40 # Build is complete COMPLETE = 40 # Build is complete
BUILD_STATUS_CODES = { BUILD_STATUS_CODES = {PENDING: _("Pending"),
PENDING : _("Pending"), HOLDING: _("Holding"),
HOLDING : _("Holding"), CANCELLED: _("Cancelled"),
CANCELLED : _("Cancelled"), COMPLETE: _("Complete"),
COMPLETE : _("Complete"), }
}
batch = models.CharField(max_length=100, blank=True, null=True, 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 of the build
status = models.PositiveIntegerField(default=PENDING, status = models.PositiveIntegerField(default=PENDING,
choices=BUILD_STATUS_CODES.items(), choices=BUILD_STATUS_CODES.items(),
validators=[MinValueValidator(0)]) validators=[MinValueValidator(0)])
# Date the build model was 'created' # Date the build model was 'created'
creation_date = models.DateField(auto_now=True, editable=False) creation_date = models.DateField(auto_now=True, editable=False)

View File

@ -15,4 +15,4 @@ build_urls = [
url(r'^(?P<pk>\d+)/', include(build_detail_urls)), url(r'^(?P<pk>\d+)/', include(build_detail_urls)),
url(r'.*$', views.BuildIndex.as_view(), name='build-index'), url(r'.*$', views.BuildIndex.as_view(), name='build-index'),
] ]

View File

@ -12,6 +12,7 @@ from .models import Build
from .forms import EditBuildForm from .forms import EditBuildForm
class BuildIndex(ListView): class BuildIndex(ListView):
model = Build model = Build
template_name = 'build/index.html' template_name = 'build/index.html'

View File

@ -18,4 +18,4 @@ class CustomerOrderLineAdmin(admin.ModelAdmin):
admin.site.register(Customer, CustomerAdmin) admin.site.register(Customer, CustomerAdmin)
admin.site.register(CustomerOrder, CustomerOrderAdmin) admin.site.register(CustomerOrder, CustomerOrderAdmin)
admin.site.register(CustomerOrderLine, CustomerOrderLineAdmin) admin.site.register(CustomerOrderLine, CustomerOrderLineAdmin)

View File

@ -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 # 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 # Only 'salable' items should be allowed in a CSO
part = models.ForeignKey(Part, blank=True, help_text="Part", 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? # 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 # Line notes
notes = models.TextField(blank=True, help_text="Line notes") notes = models.TextField(blank=True, help_text="Line notes")

View File

@ -1,3 +1,3 @@
from django.test import TestCase # from django.test import TestCase
# Create your tests here. # Create your tests here.

View File

@ -30,4 +30,4 @@ class CustomerOrderDetail(DetailView):
model = CustomerOrder model = CustomerOrder
template_name = 'customer/order_detail.html' template_name = 'customer/order_detail.html'
queryset = CustomerOrder.objects.all() queryset = CustomerOrder.objects.all()
context_object_name = 'order' context_object_name = 'order'