finish renaming SO / PO

This commit is contained in:
Matthias 2022-03-27 01:41:16 +01:00
parent 28cec5e9e5
commit 68a02af9cd
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
12 changed files with 148 additions and 148 deletions

View File

@ -637,7 +637,7 @@ class SupplierPart(models.Model):
get_price = common.models.get_price get_price = common.models.get_price
def open_orders(self): def open_orders(self):
""" Return a database query for PO line items for this SupplierPart, """ Return a database query for PurchaseOrder line items for this SupplierPart,
limited to purchase orders that are open / outstanding. limited to purchase orders that are open / outstanding.
""" """

View File

@ -92,8 +92,8 @@ class SalesOrderAdmin(ImportExportModelAdmin):
autocomplete_fields = ('customer',) autocomplete_fields = ('customer',)
class POLineItemResource(ModelResource): class PurchaseOrderLineItemResource(ModelResource):
""" Class for managing import / export of POLineItem data """ """ Class for managing import / export of PurchaseOrderLineItem data """
part_name = Field(attribute='part__part__name', readonly=True) part_name = Field(attribute='part__part__name', readonly=True)
@ -110,16 +110,16 @@ class POLineItemResource(ModelResource):
clean_model_instances = True clean_model_instances = True
class POExtraLineResource(ModelResource): class PurchaseOrderExtraLineResource(ModelResource):
""" Class for managing import / export of POExtraLine data """ """ Class for managing import / export of PurchaseOrderExtraLine data """
class Meta(GeneralExtraLineMeta): class Meta(GeneralExtraLineMeta):
model = PurchaseOrderExtraLine model = PurchaseOrderExtraLine
class SOLineItemResource(ModelResource): class SalesOrderLineItemResource(ModelResource):
""" """
Class for managing import / export of SOLineItem data Class for managing import / export of SalesOrderLineItem data
""" """
part_name = Field(attribute='part__name', readonly=True) part_name = Field(attribute='part__name', readonly=True)
@ -148,8 +148,8 @@ class SOLineItemResource(ModelResource):
clean_model_instances = True clean_model_instances = True
class SOExtraLineResource(ModelResource): class SalesOrderExtraLineResource(ModelResource):
""" Class for managing import / export of SOExtraLine data """ """ Class for managing import / export of SalesOrderExtraLine data """
class Meta(GeneralExtraLineMeta): class Meta(GeneralExtraLineMeta):
model = SalesOrderExtraLine model = SalesOrderExtraLine
@ -157,7 +157,7 @@ class SOExtraLineResource(ModelResource):
class PurchaseOrderLineItemAdmin(ImportExportModelAdmin): class PurchaseOrderLineItemAdmin(ImportExportModelAdmin):
resource_class = POLineItemResource resource_class = PurchaseOrderLineItemResource
list_display = ( list_display = (
'order', 'order',
@ -173,12 +173,12 @@ class PurchaseOrderLineItemAdmin(ImportExportModelAdmin):
class PurchaseOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin): class PurchaseOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin):
resource_class = POExtraLineResource resource_class = PurchaseOrderExtraLineResource
class SalesOrderLineItemAdmin(ImportExportModelAdmin): class SalesOrderLineItemAdmin(ImportExportModelAdmin):
resource_class = SOLineItemResource resource_class = SalesOrderLineItemResource
list_display = ( list_display = (
'order', 'order',
@ -199,7 +199,7 @@ class SalesOrderLineItemAdmin(ImportExportModelAdmin):
class SalesOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin): class SalesOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin):
resource_class = SOExtraLineResource resource_class = SalesOrderExtraLineResource
class SalesOrderShipmentAdmin(ImportExportModelAdmin): class SalesOrderShipmentAdmin(ImportExportModelAdmin):

View File

@ -20,7 +20,7 @@ from InvenTree.helpers import str2bool, DownloadFile
from InvenTree.api import AttachmentMixin from InvenTree.api import AttachmentMixin
from InvenTree.status_codes import PurchaseOrderStatus, SalesOrderStatus from InvenTree.status_codes import PurchaseOrderStatus, SalesOrderStatus
from order.admin import POLineItemResource from order.admin import PurchaseOrderLineItemResource
import order.models as models import order.models as models
import order.serializers as serializers import order.serializers as serializers
from part.models import Part from part.models import Part
@ -79,9 +79,9 @@ class GeneralExtraLineList:
] ]
class POFilter(rest_filters.FilterSet): class PurchaseOrderFilter(rest_filters.FilterSet):
""" """
Custom API filters for the POList endpoint Custom API filters for the PurchaseOrderList endpoint
""" """
assigned_to_me = rest_filters.BooleanFilter(label='assigned_to_me', method='filter_assigned_to_me') assigned_to_me = rest_filters.BooleanFilter(label='assigned_to_me', method='filter_assigned_to_me')
@ -110,16 +110,16 @@ class POFilter(rest_filters.FilterSet):
] ]
class POList(generics.ListCreateAPIView): class PurchaseOrderList(generics.ListCreateAPIView):
""" API endpoint for accessing a list of PurchaseOrder objects """ API endpoint for accessing a list of PurchaseOrder objects
- GET: Return list of PO objects (with filters) - GET: Return list of PurchaseOrder objects (with filters)
- POST: Create a new PurchaseOrder object - POST: Create a new PurchaseOrder object
""" """
queryset = models.PurchaseOrder.objects.all() queryset = models.PurchaseOrder.objects.all()
serializer_class = serializers.POSerializer serializer_class = serializers.PurchaseOrderSerializer
filterset_class = POFilter filterset_class = PurchaseOrderFilter
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
""" """
@ -156,7 +156,7 @@ class POList(generics.ListCreateAPIView):
'lines', 'lines',
) )
queryset = serializers.POSerializer.annotate_queryset(queryset) queryset = serializers.PurchaseOrderSerializer.annotate_queryset(queryset)
return queryset return queryset
@ -254,11 +254,11 @@ class POList(generics.ListCreateAPIView):
ordering = '-creation_date' ordering = '-creation_date'
class PODetail(generics.RetrieveUpdateDestroyAPIView): class PurchaseOrderDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of a PurchaseOrder object """ """ API endpoint for detail view of a PurchaseOrder object """
queryset = models.PurchaseOrder.objects.all() queryset = models.PurchaseOrder.objects.all()
serializer_class = serializers.POSerializer serializer_class = serializers.PurchaseOrderSerializer
def get_serializer(self, *args, **kwargs): def get_serializer(self, *args, **kwargs):
@ -281,12 +281,12 @@ class PODetail(generics.RetrieveUpdateDestroyAPIView):
'lines', 'lines',
) )
queryset = serializers.POSerializer.annotate_queryset(queryset) queryset = serializers.PurchaseOrderSerializer.annotate_queryset(queryset)
return queryset return queryset
class POReceive(generics.CreateAPIView): class PurchaseOrderReceive(generics.CreateAPIView):
""" """
API endpoint to receive stock items against a purchase order. API endpoint to receive stock items against a purchase order.
@ -301,7 +301,7 @@ class POReceive(generics.CreateAPIView):
queryset = models.PurchaseOrderLineItem.objects.none() queryset = models.PurchaseOrderLineItem.objects.none()
serializer_class = serializers.POReceiveSerializer serializer_class = serializers.PurchaseOrderReceiveSerializer
def get_serializer_context(self): def get_serializer_context(self):
@ -318,9 +318,9 @@ class POReceive(generics.CreateAPIView):
return context return context
class POLineItemFilter(rest_filters.FilterSet): class PurchaseOrderLineItemFilter(rest_filters.FilterSet):
""" """
Custom filters for the POLineItemList endpoint Custom filters for the PurchaseOrderLineItemList endpoint
""" """
class Meta: class Meta:
@ -370,22 +370,22 @@ class POLineItemFilter(rest_filters.FilterSet):
return queryset return queryset
class POLineItemList(generics.ListCreateAPIView): class PurchaseOrderLineItemList(generics.ListCreateAPIView):
""" API endpoint for accessing a list of POLineItem objects """ API endpoint for accessing a list of PurchaseOrderLineItem objects
- GET: Return a list of PO Line Item objects - GET: Return a list of PurchaseOrder Line Item objects
- POST: Create a new PurchaseOrderLineItem object - POST: Create a new PurchaseOrderLineItem object
""" """
queryset = models.PurchaseOrderLineItem.objects.all() queryset = models.PurchaseOrderLineItem.objects.all()
serializer_class = serializers.POLineItemSerializer serializer_class = serializers.PurchaseOrderLineItemSerializer
filterset_class = POLineItemFilter filterset_class = PurchaseOrderLineItemFilter
def get_queryset(self, *args, **kwargs): def get_queryset(self, *args, **kwargs):
queryset = super().get_queryset(*args, **kwargs) queryset = super().get_queryset(*args, **kwargs)
queryset = serializers.POLineItemSerializer.annotate_queryset(queryset) queryset = serializers.PurchaseOrderLineItemSerializer.annotate_queryset(queryset)
return queryset return queryset
@ -434,7 +434,7 @@ class POLineItemList(generics.ListCreateAPIView):
export_format = str(export_format).strip().lower() export_format = str(export_format).strip().lower()
if export_format in ['csv', 'tsv', 'xls', 'xlsx']: if export_format in ['csv', 'tsv', 'xls', 'xlsx']:
dataset = POLineItemResource().export(queryset=queryset) dataset = PurchaseOrderLineItemResource().export(queryset=queryset)
filedata = dataset.export(export_format) filedata = dataset.export(export_format)
@ -484,46 +484,46 @@ class POLineItemList(generics.ListCreateAPIView):
] ]
class POLineItemDetail(generics.RetrieveUpdateDestroyAPIView): class PurchaseOrderLineItemDetail(generics.RetrieveUpdateDestroyAPIView):
""" """
Detail API endpoint for PurchaseOrderLineItem object Detail API endpoint for PurchaseOrderLineItem object
""" """
queryset = models.PurchaseOrderLineItem.objects.all() queryset = models.PurchaseOrderLineItem.objects.all()
serializer_class = serializers.POLineItemSerializer serializer_class = serializers.PurchaseOrderLineItemSerializer
def get_queryset(self): def get_queryset(self):
queryset = super().get_queryset() queryset = super().get_queryset()
queryset = serializers.POLineItemSerializer.annotate_queryset(queryset) queryset = serializers.PurchaseOrderLineItemSerializer.annotate_queryset(queryset)
return queryset return queryset
class POExtraLineList(GeneralExtraLineList, generics.ListCreateAPIView): class PurchaseOrderExtraLineList(GeneralExtraLineList, generics.ListCreateAPIView):
""" """
API endpoint for accessing a list of PurchaseOrderExtraLine objects. API endpoint for accessing a list of PurchaseOrderExtraLine objects.
""" """
queryset = models.PurchaseOrderExtraLine.objects.all() queryset = models.PurchaseOrderExtraLine.objects.all()
serializer_class = serializers.POExtraLineSerializer serializer_class = serializers.PurchaseOrderExtraLineSerializer
class POExtraLineDetail(generics.RetrieveUpdateDestroyAPIView): class PurchaseOrderExtraLineDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of a PurchaseOrderExtraLine object """ """ API endpoint for detail view of a PurchaseOrderExtraLine object """
queryset = models.PurchaseOrderExtraLine.objects.all() queryset = models.PurchaseOrderExtraLine.objects.all()
serializer_class = serializers.POExtraLineSerializer serializer_class = serializers.PurchaseOrderExtraLineSerializer
class SOAttachmentList(generics.ListCreateAPIView, AttachmentMixin): class SalesOrderAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
""" """
API endpoint for listing (and creating) a SalesOrderAttachment (file upload) API endpoint for listing (and creating) a SalesOrderAttachment (file upload)
""" """
queryset = models.SalesOrderAttachment.objects.all() queryset = models.SalesOrderAttachment.objects.all()
serializer_class = serializers.SOAttachmentSerializer serializer_class = serializers.SalesOrderAttachmentSerializer
filter_backends = [ filter_backends = [
rest_filters.DjangoFilterBackend, rest_filters.DjangoFilterBackend,
@ -534,20 +534,20 @@ class SOAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
] ]
class SOAttachmentDetail(generics.RetrieveUpdateDestroyAPIView, AttachmentMixin): class SalesOrderAttachmentDetail(generics.RetrieveUpdateDestroyAPIView, AttachmentMixin):
""" """
Detail endpoint for SalesOrderAttachment Detail endpoint for SalesOrderAttachment
""" """
queryset = models.SalesOrderAttachment.objects.all() queryset = models.SalesOrderAttachment.objects.all()
serializer_class = serializers.SOAttachmentSerializer serializer_class = serializers.SalesOrderAttachmentSerializer
class SOList(generics.ListCreateAPIView): class SalesOrderList(generics.ListCreateAPIView):
""" """
API endpoint for accessing a list of SalesOrder objects. API endpoint for accessing a list of SalesOrder objects.
- GET: Return list of SO objects (with filters) - GET: Return list of SalesOrder objects (with filters)
- POST: Create a new SalesOrder - POST: Create a new SalesOrder
""" """
@ -684,7 +684,7 @@ class SOList(generics.ListCreateAPIView):
ordering = '-creation_date' ordering = '-creation_date'
class SODetail(generics.RetrieveUpdateDestroyAPIView): class SalesOrderDetail(generics.RetrieveUpdateDestroyAPIView):
""" """
API endpoint for detail view of a SalesOrder object. API endpoint for detail view of a SalesOrder object.
""" """
@ -714,9 +714,9 @@ class SODetail(generics.RetrieveUpdateDestroyAPIView):
return queryset return queryset
class SOLineItemFilter(rest_filters.FilterSet): class SalesOrderLineItemFilter(rest_filters.FilterSet):
""" """
Custom filters for SOLineItemList endpoint Custom filters for SalesOrderLineItemList endpoint
""" """
class Meta: class Meta:
@ -747,14 +747,14 @@ class SOLineItemFilter(rest_filters.FilterSet):
return queryset return queryset
class SOLineItemList(generics.ListCreateAPIView): class SalesOrderLineItemList(generics.ListCreateAPIView):
""" """
API endpoint for accessing a list of SalesOrderLineItem objects. API endpoint for accessing a list of SalesOrderLineItem objects.
""" """
queryset = models.SalesOrderLineItem.objects.all() queryset = models.SalesOrderLineItem.objects.all()
serializer_class = serializers.SOLineItemSerializer serializer_class = serializers.SalesOrderLineItemSerializer
filterset_class = SOLineItemFilter filterset_class = SalesOrderLineItemFilter
def get_serializer(self, *args, **kwargs): def get_serializer(self, *args, **kwargs):
@ -811,27 +811,27 @@ class SOLineItemList(generics.ListCreateAPIView):
] ]
class SOExtraLineList(GeneralExtraLineList, generics.ListCreateAPIView): class SalesOrderExtraLineList(GeneralExtraLineList, generics.ListCreateAPIView):
""" """
API endpoint for accessing a list of SalesOrderExtraLine objects. API endpoint for accessing a list of SalesOrderExtraLine objects.
""" """
queryset = models.SalesOrderExtraLine.objects.all() queryset = models.SalesOrderExtraLine.objects.all()
serializer_class = serializers.SOExtraLineSerializer serializer_class = serializers.SalesOrderExtraLineSerializer
class SOExtraLineDetail(generics.RetrieveUpdateDestroyAPIView): class SalesOrderExtraLineDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of a SalesOrderExtraLine object """ """ API endpoint for detail view of a SalesOrderExtraLine object """
queryset = models.SalesOrderExtraLine.objects.all() queryset = models.SalesOrderExtraLine.objects.all()
serializer_class = serializers.SOExtraLineSerializer serializer_class = serializers.SalesOrderExtraLineSerializer
class SOLineItemDetail(generics.RetrieveUpdateDestroyAPIView): class SalesOrderLineItemDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of a SalesOrderLineItem object """ """ API endpoint for detail view of a SalesOrderLineItem object """
queryset = models.SalesOrderLineItem.objects.all() queryset = models.SalesOrderLineItem.objects.all()
serializer_class = serializers.SOLineItemSerializer serializer_class = serializers.SalesOrderLineItemSerializer
class SalesOrderComplete(generics.CreateAPIView): class SalesOrderComplete(generics.CreateAPIView):
@ -863,7 +863,7 @@ class SalesOrderAllocateSerials(generics.CreateAPIView):
""" """
queryset = models.SalesOrder.objects.none() queryset = models.SalesOrder.objects.none()
serializer_class = serializers.SOSerialAllocationSerializer serializer_class = serializers.SalesOrderSerialAllocationSerializer
def get_serializer_context(self): def get_serializer_context(self):
@ -885,11 +885,11 @@ class SalesOrderAllocate(generics.CreateAPIView):
API endpoint to allocate stock items against a SalesOrder API endpoint to allocate stock items against a SalesOrder
- The SalesOrder is specified in the URL - The SalesOrder is specified in the URL
- See the SOShipmentAllocationSerializer class - See the SalesOrderShipmentAllocationSerializer class
""" """
queryset = models.SalesOrder.objects.none() queryset = models.SalesOrder.objects.none()
serializer_class = serializers.SOShipmentAllocationSerializer serializer_class = serializers.SalesOrderShipmentAllocationSerializer
def get_serializer_context(self): def get_serializer_context(self):
@ -906,7 +906,7 @@ class SalesOrderAllocate(generics.CreateAPIView):
return ctx return ctx
class SOAllocationDetail(generics.RetrieveUpdateDestroyAPIView): class SalesOrderAllocationDetail(generics.RetrieveUpdateDestroyAPIView):
""" """
API endpoint for detali view of a SalesOrderAllocation object API endpoint for detali view of a SalesOrderAllocation object
""" """
@ -915,7 +915,7 @@ class SOAllocationDetail(generics.RetrieveUpdateDestroyAPIView):
serializer_class = serializers.SalesOrderAllocationSerializer serializer_class = serializers.SalesOrderAllocationSerializer
class SOAllocationList(generics.ListAPIView): class SalesOrderAllocationList(generics.ListAPIView):
""" """
API endpoint for listing SalesOrderAllocation objects API endpoint for listing SalesOrderAllocation objects
""" """
@ -993,9 +993,9 @@ class SOAllocationList(generics.ListAPIView):
] ]
class SOShipmentFilter(rest_filters.FilterSet): class SalesOrderShipmentFilter(rest_filters.FilterSet):
""" """
Custom filterset for the SOShipmentList endpoint Custom filterset for the SalesOrderShipmentList endpoint
""" """
shipped = rest_filters.BooleanFilter(label='shipped', method='filter_shipped') shipped = rest_filters.BooleanFilter(label='shipped', method='filter_shipped')
@ -1018,21 +1018,21 @@ class SOShipmentFilter(rest_filters.FilterSet):
] ]
class SOShipmentList(generics.ListCreateAPIView): class SalesOrderShipmentList(generics.ListCreateAPIView):
""" """
API list endpoint for SalesOrderShipment model API list endpoint for SalesOrderShipment model
""" """
queryset = models.SalesOrderShipment.objects.all() queryset = models.SalesOrderShipment.objects.all()
serializer_class = serializers.SalesOrderShipmentSerializer serializer_class = serializers.SalesOrderShipmentSerializer
filterset_class = SOShipmentFilter filterset_class = SalesOrderShipmentFilter
filter_backends = [ filter_backends = [
rest_filters.DjangoFilterBackend, rest_filters.DjangoFilterBackend,
] ]
class SOShipmentDetail(generics.RetrieveUpdateDestroyAPIView): class SalesOrderShipmentDetail(generics.RetrieveUpdateDestroyAPIView):
""" """
API detail endpooint for SalesOrderShipment model API detail endpooint for SalesOrderShipment model
""" """
@ -1041,7 +1041,7 @@ class SOShipmentDetail(generics.RetrieveUpdateDestroyAPIView):
serializer_class = serializers.SalesOrderShipmentSerializer serializer_class = serializers.SalesOrderShipmentSerializer
class SOShipmentComplete(generics.CreateAPIView): class SalesOrderShipmentComplete(generics.CreateAPIView):
""" """
API endpoint for completing (shipping) a SalesOrderShipment API endpoint for completing (shipping) a SalesOrderShipment
""" """
@ -1067,13 +1067,13 @@ class SOShipmentComplete(generics.CreateAPIView):
return ctx return ctx
class POAttachmentList(generics.ListCreateAPIView, AttachmentMixin): class PurchaseOrderAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
""" """
API endpoint for listing (and creating) a PurchaseOrderAttachment (file upload) API endpoint for listing (and creating) a PurchaseOrderAttachment (file upload)
""" """
queryset = models.PurchaseOrderAttachment.objects.all() queryset = models.PurchaseOrderAttachment.objects.all()
serializer_class = serializers.POAttachmentSerializer serializer_class = serializers.PurchaseOrderAttachmentSerializer
filter_backends = [ filter_backends = [
rest_filters.DjangoFilterBackend, rest_filters.DjangoFilterBackend,
@ -1084,13 +1084,13 @@ class POAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
] ]
class POAttachmentDetail(generics.RetrieveUpdateDestroyAPIView, AttachmentMixin): class PurchaseOrderAttachmentDetail(generics.RetrieveUpdateDestroyAPIView, AttachmentMixin):
""" """
Detail endpoint for a PurchaseOrderAttachment Detail endpoint for a PurchaseOrderAttachment
""" """
queryset = models.PurchaseOrderAttachment.objects.all() queryset = models.PurchaseOrderAttachment.objects.all()
serializer_class = serializers.POAttachmentSerializer serializer_class = serializers.PurchaseOrderAttachmentSerializer
order_api_urls = [ order_api_urls = [
@ -1100,45 +1100,45 @@ order_api_urls = [
# Purchase order attachments # Purchase order attachments
url(r'attachment/', include([ url(r'attachment/', include([
url(r'^(?P<pk>\d+)/$', POAttachmentDetail.as_view(), name='api-po-attachment-detail'), url(r'^(?P<pk>\d+)/$', PurchaseOrderAttachmentDetail.as_view(), name='api-po-attachment-detail'),
url(r'^.*$', POAttachmentList.as_view(), name='api-po-attachment-list'), url(r'^.*$', PurchaseOrderAttachmentList.as_view(), name='api-po-attachment-list'),
])), ])),
# Individual purchase order detail URLs # Individual purchase order detail URLs
url(r'^(?P<pk>\d+)/', include([ url(r'^(?P<pk>\d+)/', include([
url(r'^receive/', POReceive.as_view(), name='api-po-receive'), url(r'^receive/', PurchaseOrderReceive.as_view(), name='api-po-receive'),
url(r'.*$', PODetail.as_view(), name='api-po-detail'), url(r'.*$', PurchaseOrderDetail.as_view(), name='api-po-detail'),
])), ])),
# Purchase order list # Purchase order list
url(r'^.*$', POList.as_view(), name='api-po-list'), url(r'^.*$', PurchaseOrderList.as_view(), name='api-po-list'),
])), ])),
# API endpoints for purchase order line items # API endpoints for purchase order line items
url(r'^po-line/', include([ url(r'^po-line/', include([
url(r'^(?P<pk>\d+)/$', POLineItemDetail.as_view(), name='api-po-line-detail'), url(r'^(?P<pk>\d+)/$', PurchaseOrderLineItemDetail.as_view(), name='api-po-line-detail'),
url(r'^.*$', POLineItemList.as_view(), name='api-po-line-list'), url(r'^.*$', PurchaseOrderLineItemList.as_view(), name='api-po-line-list'),
])), ])),
# API endpoints for purchase order extra line # API endpoints for purchase order extra line
url(r'^po-extra-line/', include([ url(r'^po-extra-line/', include([
url(r'^(?P<pk>\d+)/$', POExtraLineDetail.as_view(), name='api-po-extra-line-detail'), url(r'^(?P<pk>\d+)/$', PurchaseOrderExtraLineDetail.as_view(), name='api-po-extra-line-detail'),
url(r'^$', POExtraLineList.as_view(), name='api-po-extra-line-list'), url(r'^$', PurchaseOrderExtraLineList.as_view(), name='api-po-extra-line-list'),
])), ])),
# API endpoints for sales ordesr # API endpoints for sales ordesr
url(r'^so/', include([ url(r'^so/', include([
url(r'attachment/', include([ url(r'attachment/', include([
url(r'^(?P<pk>\d+)/$', SOAttachmentDetail.as_view(), name='api-so-attachment-detail'), url(r'^(?P<pk>\d+)/$', SalesOrderAttachmentDetail.as_view(), name='api-so-attachment-detail'),
url(r'^.*$', SOAttachmentList.as_view(), name='api-so-attachment-list'), url(r'^.*$', SalesOrderAttachmentList.as_view(), name='api-so-attachment-list'),
])), ])),
url(r'^shipment/', include([ url(r'^shipment/', include([
url(r'^(?P<pk>\d+)/', include([ url(r'^(?P<pk>\d+)/', include([
url(r'^ship/$', SOShipmentComplete.as_view(), name='api-so-shipment-ship'), url(r'^ship/$', SalesOrderShipmentComplete.as_view(), name='api-so-shipment-ship'),
url(r'^.*$', SOShipmentDetail.as_view(), name='api-so-shipment-detail'), url(r'^.*$', SalesOrderShipmentDetail.as_view(), name='api-so-shipment-detail'),
])), ])),
url(r'^.*$', SOShipmentList.as_view(), name='api-so-shipment-list'), url(r'^.*$', SalesOrderShipmentList.as_view(), name='api-so-shipment-list'),
])), ])),
# Sales order detail view # Sales order detail view
@ -1146,28 +1146,28 @@ order_api_urls = [
url(r'^complete/', SalesOrderComplete.as_view(), name='api-so-complete'), url(r'^complete/', SalesOrderComplete.as_view(), name='api-so-complete'),
url(r'^allocate/', SalesOrderAllocate.as_view(), name='api-so-allocate'), url(r'^allocate/', SalesOrderAllocate.as_view(), name='api-so-allocate'),
url(r'^allocate-serials/', SalesOrderAllocateSerials.as_view(), name='api-so-allocate-serials'), url(r'^allocate-serials/', SalesOrderAllocateSerials.as_view(), name='api-so-allocate-serials'),
url(r'^.*$', SODetail.as_view(), name='api-so-detail'), url(r'^.*$', SalesOrderDetail.as_view(), name='api-so-detail'),
])), ])),
# Sales order list view # Sales order list view
url(r'^.*$', SOList.as_view(), name='api-so-list'), url(r'^.*$', SalesOrderList.as_view(), name='api-so-list'),
])), ])),
# API endpoints for sales order line items # API endpoints for sales order line items
url(r'^so-line/', include([ url(r'^so-line/', include([
url(r'^(?P<pk>\d+)/$', SOLineItemDetail.as_view(), name='api-so-line-detail'), url(r'^(?P<pk>\d+)/$', SalesOrderLineItemDetail.as_view(), name='api-so-line-detail'),
url(r'^$', SOLineItemList.as_view(), name='api-so-line-list'), url(r'^$', SalesOrderLineItemList.as_view(), name='api-so-line-list'),
])), ])),
# API endpoints for sales order extra line # API endpoints for sales order extra line
url(r'^so-extra-line/', include([ url(r'^so-extra-line/', include([
url(r'^(?P<pk>\d+)/$', SOExtraLineDetail.as_view(), name='api-so-extra-line-detail'), url(r'^(?P<pk>\d+)/$', SalesOrderExtraLineDetail.as_view(), name='api-so-extra-line-detail'),
url(r'^$', SOExtraLineList.as_view(), name='api-so-extra-line-list'), url(r'^$', SalesOrderExtraLineList.as_view(), name='api-so-extra-line-list'),
])), ])),
# API endpoints for sales order allocations # API endpoints for sales order allocations
url(r'^so-allocation/', include([ url(r'^so-allocation/', include([
url(r'^(?P<pk>\d+)/$', SOAllocationDetail.as_view(), name='api-so-allocation-detail'), url(r'^(?P<pk>\d+)/$', SalesOrderAllocationDetail.as_view(), name='api-so-allocation-detail'),
url(r'^.*$', SOAllocationList.as_view(), name='api-so-allocation-list'), url(r'^.*$', SalesOrderAllocationList.as_view(), name='api-so-allocation-list'),
])), ])),
] ]

View File

@ -309,7 +309,7 @@ class PurchaseOrder(Order):
raise ValidationError({'supplier': _("Part supplier must match PO supplier")}) raise ValidationError({'supplier': _("Part supplier must match PO supplier")})
if group: if group:
# Check if there is already a matching line item (for this PO) # Check if there is already a matching line item (for this PurchaseOrder)
matches = self.lines.filter(part=supplier_part) matches = self.lines.filter(part=supplier_part)
if matches.count() > 0: if matches.count() > 0:
@ -424,7 +424,7 @@ class PurchaseOrder(Order):
@transaction.atomic @transaction.atomic
def receive_line_item(self, line, location, quantity, user, status=StockStatus.OK, **kwargs): def receive_line_item(self, line, location, quantity, user, status=StockStatus.OK, **kwargs):
""" """
Receive a line item (or partial line item) against this PO Receive a line item (or partial line item) against this PurchaseOrder
""" """
# Extract optional batch code for the new stock item # Extract optional batch code for the new stock item

View File

@ -96,7 +96,7 @@ class AbstractExtraLineMeta:
] ]
class POSerializer(AbstractOrderSerializer, ReferenceIndexingSerializerMixin, InvenTreeModelSerializer): class PurchaseOrderSerializer(AbstractOrderSerializer, ReferenceIndexingSerializerMixin, InvenTreeModelSerializer):
""" Serializer for a PurchaseOrder object """ """ Serializer for a PurchaseOrder object """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -178,7 +178,7 @@ class POSerializer(AbstractOrderSerializer, ReferenceIndexingSerializerMixin, In
] ]
class POLineItemSerializer(InvenTreeModelSerializer): class PurchaseOrderLineItemSerializer(InvenTreeModelSerializer):
@staticmethod @staticmethod
def annotate_queryset(queryset): def annotate_queryset(queryset):
@ -245,7 +245,7 @@ class POLineItemSerializer(InvenTreeModelSerializer):
help_text=_('Purchase price currency'), help_text=_('Purchase price currency'),
) )
order_detail = POSerializer(source='order', read_only=True, many=False) order_detail = PurchaseOrderSerializer(source='order', read_only=True, many=False)
class Meta: class Meta:
model = order.models.PurchaseOrderLineItem model = order.models.PurchaseOrderLineItem
@ -272,16 +272,16 @@ class POLineItemSerializer(InvenTreeModelSerializer):
] ]
class POExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer): class PurchaseOrderExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):
""" Serializer for a PurchaseOrderExtraLine object """ """ Serializer for a PurchaseOrderExtraLine object """
order_detail = POSerializer(source='order', many=False, read_only=True) order_detail = PurchaseOrderSerializer(source='order', many=False, read_only=True)
class Meta(AbstractExtraLineMeta): class Meta(AbstractExtraLineMeta):
model = order.models.PurchaseOrderExtraLine model = order.models.PurchaseOrderExtraLine
class POLineItemReceiveSerializer(serializers.Serializer): class PurchaseOrderLineItemReceiveSerializer(serializers.Serializer):
""" """
A serializer for receiving a single purchase order line item against a purchase order A serializer for receiving a single purchase order line item against a purchase order
""" """
@ -411,12 +411,12 @@ class POLineItemReceiveSerializer(serializers.Serializer):
return data return data
class POReceiveSerializer(serializers.Serializer): class PurchaseOrderReceiveSerializer(serializers.Serializer):
""" """
Serializer for receiving items against a purchase order Serializer for receiving items against a purchase order
""" """
items = POLineItemReceiveSerializer(many=True) items = PurchaseOrderLineItemReceiveSerializer(many=True)
location = serializers.PrimaryKeyRelatedField( location = serializers.PrimaryKeyRelatedField(
queryset=stock.models.StockLocation.objects.all(), queryset=stock.models.StockLocation.objects.all(),
@ -511,7 +511,7 @@ class POReceiveSerializer(serializers.Serializer):
] ]
class POAttachmentSerializer(InvenTreeAttachmentSerializer): class PurchaseOrderAttachmentSerializer(InvenTreeAttachmentSerializer):
""" """
Serializers for the PurchaseOrderAttachment model Serializers for the PurchaseOrderAttachment model
""" """
@ -681,7 +681,7 @@ class SalesOrderAllocationSerializer(InvenTreeModelSerializer):
] ]
class SOLineItemSerializer(InvenTreeModelSerializer): class SalesOrderLineItemSerializer(InvenTreeModelSerializer):
""" Serializer for a SalesOrderLineItem object """ """ Serializer for a SalesOrderLineItem object """
@staticmethod @staticmethod
@ -931,7 +931,7 @@ class SalesOrderCompleteSerializer(serializers.Serializer):
order.complete_order(user) order.complete_order(user)
class SOSerialAllocationSerializer(serializers.Serializer): class SalesOrderSerialAllocationSerializer(serializers.Serializer):
""" """
DRF serializer for allocation of serial numbers against a sales order / shipment DRF serializer for allocation of serial numbers against a sales order / shipment
""" """
@ -1094,7 +1094,7 @@ class SOSerialAllocationSerializer(serializers.Serializer):
) )
class SOShipmentAllocationSerializer(serializers.Serializer): class SalesOrderShipmentAllocationSerializer(serializers.Serializer):
""" """
DRF serializer for allocation of stock items against a sales order / shipment DRF serializer for allocation of stock items against a sales order / shipment
""" """
@ -1168,7 +1168,7 @@ class SOShipmentAllocationSerializer(serializers.Serializer):
) )
class SOExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer): class SalesOrderExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):
""" Serializer for a SalesOrderExtraLine object """ """ Serializer for a SalesOrderExtraLine object """
order_detail = SalesOrderSerializer(source='order', many=False, read_only=True) order_detail = SalesOrderSerializer(source='order', many=False, read_only=True)
@ -1177,7 +1177,7 @@ class SOExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerialize
model = order.models.SalesOrderExtraLine model = order.models.SalesOrderExtraLine
class SOAttachmentSerializer(InvenTreeAttachmentSerializer): class SalesOrderAttachmentSerializer(InvenTreeAttachmentSerializer):
""" """
Serializers for the SalesOrderAttachment model Serializers for the SalesOrderAttachment model
""" """

View File

@ -63,7 +63,7 @@ class PurchaseOrderTest(OrderTest):
def test_po_list(self): def test_po_list(self):
# List *ALL* PO items # List *ALL* PurchaseOrder items
self.filter({}, 7) self.filter({}, 7)
# Filter by supplier # Filter by supplier
@ -175,7 +175,7 @@ class PurchaseOrderTest(OrderTest):
pk = response.data['pk'] pk = response.data['pk']
# Try to create a PO with identical reference (should fail!) # Try to create a PurchaseOrder with identical reference (should fail!)
response = self.post( response = self.post(
url, url,
{ {
@ -493,7 +493,7 @@ class PurchaseOrderReceiveTest(OrderTest):
self.assertIn('can only be received against', str(response.data)) self.assertIn('can only be received against', str(response.data))
# Now, set the PO back to "PLACED" so the items can be received # Now, set the PurchaseOrder back to "PLACED" so the items can be received
order.status = PurchaseOrderStatus.PLACED order.status = PurchaseOrderStatus.PLACED
order.save() order.save()

View File

@ -20,7 +20,7 @@ from decimal import Decimal, InvalidOperation
from .models import PurchaseOrder, PurchaseOrderLineItem from .models import PurchaseOrder, PurchaseOrderLineItem
from .models import SalesOrder, SalesOrderLineItem from .models import SalesOrder, SalesOrderLineItem
from .admin import POLineItemResource, SOLineItemResource from .admin import PurchaseOrderLineItemResource, SalesOrderLineItemResource
from build.models import Build from build.models import Build
from company.models import Company, SupplierPart # ManufacturerPart from company.models import Company, SupplierPart # ManufacturerPart
from stock.models import StockItem from stock.models import StockItem
@ -410,7 +410,7 @@ class SalesOrderExport(AjaxView):
filename = f"{str(order)} - {order.customer.name}.{export_format}" filename = f"{str(order)} - {order.customer.name}.{export_format}"
dataset = SOLineItemResource().export(queryset=order.lines.all()) dataset = SalesOrderLineItemResource().export(queryset=order.lines.all())
filedata = dataset.export(format=export_format) filedata = dataset.export(format=export_format)
@ -441,7 +441,7 @@ class PurchaseOrderExport(AjaxView):
fmt=export_format fmt=export_format
) )
dataset = POLineItemResource().export(queryset=order.lines.all()) dataset = PurchaseOrderLineItemResource().export(queryset=order.lines.all())
filedata = dataset.export(format=export_format) filedata = dataset.export(format=export_format)
@ -491,7 +491,7 @@ class OrderParts(AjaxView):
return data return data
def get_suppliers(self): def get_suppliers(self):
""" Calculates a list of suppliers which the user will need to create POs for. """ Calculates a list of suppliers which the user will need to create PurchaseOrders for.
This is calculated AFTER the user finishes selecting the parts to order. This is calculated AFTER the user finishes selecting the parts to order.
Crucially, get_parts() must be called before get_suppliers() Crucially, get_parts() must be called before get_suppliers()
""" """

View File

@ -31,8 +31,8 @@ from .models import SalesOrderReport
from .serializers import TestReportSerializer from .serializers import TestReportSerializer
from .serializers import BuildReportSerializer from .serializers import BuildReportSerializer
from .serializers import BOMReportSerializer from .serializers import BOMReportSerializer
from .serializers import POReportSerializer from .serializers import PurchaseOrderReportSerializer
from .serializers import SOReportSerializer from .serializers import SalesOrderReportSerializer
class ReportListView(generics.ListAPIView): class ReportListView(generics.ListAPIView):
@ -561,12 +561,12 @@ class BuildReportPrint(generics.RetrieveAPIView, BuildReportMixin, ReportPrintMi
return self.print(request, builds) return self.print(request, builds)
class POReportList(ReportListView, OrderReportMixin): class PurchaseOrderReportList(ReportListView, OrderReportMixin):
OrderModel = order.models.PurchaseOrder OrderModel = order.models.PurchaseOrder
queryset = PurchaseOrderReport.objects.all() queryset = PurchaseOrderReport.objects.all()
serializer_class = POReportSerializer serializer_class = PurchaseOrderReportSerializer
def filter_queryset(self, queryset): def filter_queryset(self, queryset):
@ -618,16 +618,16 @@ class POReportList(ReportListView, OrderReportMixin):
return queryset return queryset
class POReportDetail(generics.RetrieveUpdateDestroyAPIView): class PurchaseOrderReportDetail(generics.RetrieveUpdateDestroyAPIView):
""" """
API endpoint for a single PurchaseOrderReport object API endpoint for a single PurchaseOrderReport object
""" """
queryset = PurchaseOrderReport.objects.all() queryset = PurchaseOrderReport.objects.all()
serializer_class = POReportSerializer serializer_class = PurchaseOrderReportSerializer
class POReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin): class PurchaseOrderReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin):
""" """
API endpoint for printing a PurchaseOrderReport object API endpoint for printing a PurchaseOrderReport object
""" """
@ -635,7 +635,7 @@ class POReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin
OrderModel = order.models.PurchaseOrder OrderModel = order.models.PurchaseOrder
queryset = PurchaseOrderReport.objects.all() queryset = PurchaseOrderReport.objects.all()
serializer_class = POReportSerializer serializer_class = PurchaseOrderReportSerializer
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
@ -644,12 +644,12 @@ class POReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin
return self.print(request, orders) return self.print(request, orders)
class SOReportList(ReportListView, OrderReportMixin): class SalesOrderReportList(ReportListView, OrderReportMixin):
OrderModel = order.models.SalesOrder OrderModel = order.models.SalesOrder
queryset = SalesOrderReport.objects.all() queryset = SalesOrderReport.objects.all()
serializer_class = SOReportSerializer serializer_class = SalesOrderReportSerializer
def filter_queryset(self, queryset): def filter_queryset(self, queryset):
@ -701,16 +701,16 @@ class SOReportList(ReportListView, OrderReportMixin):
return queryset return queryset
class SOReportDetail(generics.RetrieveUpdateDestroyAPIView): class SalesOrderReportDetail(generics.RetrieveUpdateDestroyAPIView):
""" """
API endpoint for a single SalesOrderReport object API endpoint for a single SalesOrderReport object
""" """
queryset = SalesOrderReport.objects.all() queryset = SalesOrderReport.objects.all()
serializer_class = SOReportSerializer serializer_class = SalesOrderReportSerializer
class SOReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin): class SalesOrderReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin):
""" """
API endpoint for printing a PurchaseOrderReport object API endpoint for printing a PurchaseOrderReport object
""" """
@ -718,7 +718,7 @@ class SOReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin
OrderModel = order.models.SalesOrder OrderModel = order.models.SalesOrder
queryset = SalesOrderReport.objects.all() queryset = SalesOrderReport.objects.all()
serializer_class = SOReportSerializer serializer_class = SalesOrderReportSerializer
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
@ -733,23 +733,23 @@ report_api_urls = [
url(r'po/', include([ url(r'po/', include([
# Detail views # Detail views
url(r'^(?P<pk>\d+)/', include([ url(r'^(?P<pk>\d+)/', include([
url(r'print/', POReportPrint.as_view(), name='api-po-report-print'), url(r'print/', PurchaseOrderReportPrint.as_view(), name='api-po-report-print'),
url(r'^$', POReportDetail.as_view(), name='api-po-report-detail'), url(r'^$', PurchaseOrderReportDetail.as_view(), name='api-po-report-detail'),
])), ])),
# List view # List view
url(r'^$', POReportList.as_view(), name='api-po-report-list'), url(r'^$', PurchaseOrderReportList.as_view(), name='api-po-report-list'),
])), ])),
# Sales order reports # Sales order reports
url(r'so/', include([ url(r'so/', include([
# Detail views # Detail views
url(r'^(?P<pk>\d+)/', include([ url(r'^(?P<pk>\d+)/', include([
url(r'print/', SOReportPrint.as_view(), name='api-so-report-print'), url(r'print/', SalesOrderReportPrint.as_view(), name='api-so-report-print'),
url(r'^$', SOReportDetail.as_view(), name='api-so-report-detail'), url(r'^$', SalesOrderReportDetail.as_view(), name='api-so-report-detail'),
])), ])),
url(r'^$', SOReportList.as_view(), name='api-so-report-list'), url(r'^$', SalesOrderReportList.as_view(), name='api-so-report-list'),
])), ])),
# Build reports # Build reports

View File

@ -58,7 +58,7 @@ class BOMReportSerializer(InvenTreeModelSerializer):
] ]
class POReportSerializer(InvenTreeModelSerializer): class PurchaseOrderReportSerializer(InvenTreeModelSerializer):
template = InvenTreeAttachmentSerializerField(required=True) template = InvenTreeAttachmentSerializerField(required=True)
@ -74,7 +74,7 @@ class POReportSerializer(InvenTreeModelSerializer):
] ]
class SOReportSerializer(InvenTreeModelSerializer): class SalesOrderReportSerializer(InvenTreeModelSerializer):
template = InvenTreeAttachmentSerializerField(required=True) template = InvenTreeAttachmentSerializerField(required=True)

View File

@ -36,7 +36,7 @@ from InvenTree.filters import InvenTreeOrderingFilter
from order.models import PurchaseOrder from order.models import PurchaseOrder
from order.models import SalesOrder, SalesOrderAllocation from order.models import SalesOrder, SalesOrderAllocation
from order.serializers import POSerializer from order.serializers import PurchaseOrderSerializer
from part.models import BomItem, Part, PartCategory from part.models import BomItem, Part, PartCategory
from part.serializers import PartBriefSerializer from part.serializers import PartBriefSerializer
@ -1220,7 +1220,7 @@ class StockTrackingList(generics.ListAPIView):
if 'purchaseorder' in deltas: if 'purchaseorder' in deltas:
try: try:
order = PurchaseOrder.objects.get(pk=deltas['purchaseorder']) order = PurchaseOrder.objects.get(pk=deltas['purchaseorder'])
serializer = POSerializer(order) serializer = PurchaseOrderSerializer(order)
deltas['purchaseorder_detail'] = serializer.data deltas['purchaseorder_detail'] = serializer.data
except: except:
pass pass

View File

@ -276,7 +276,7 @@ function createPurchaseOrder(options={}) {
if (options.onSuccess) { if (options.onSuccess) {
options.onSuccess(data); options.onSuccess(data);
} else { } else {
// Default action is to redirect browser to the new PO // Default action is to redirect browser to the new PurchaseOrder
location.href = `/order/purchase-order/${data.pk}/`; location.href = `/order/purchase-order/${data.pk}/`;
} }
}, },
@ -528,7 +528,7 @@ function newPurchaseOrderFromOrderWizard(e) {
/** /**
* Receive stock items against a PurchaseOrder * Receive stock items against a PurchaseOrder
* Uses the POReceive API endpoint * Uses the PurchaseOrderReceive API endpoint
* *
* arguments: * arguments:
* - order_id, ID / PK for the PurchaseOrder instance * - order_id, ID / PK for the PurchaseOrder instance

View File

@ -271,7 +271,7 @@ function printBomReports(parts) {
function printPurchaseOrderReports(orders) { function printPurchaseOrderReports(orders) {
/** /**
* Print PO reports for the provided purchase order(s) * Print PurchaseOrder reports for the provided purchase order(s)
*/ */
if (orders.length == 0) { if (orders.length == 0) {
@ -325,7 +325,7 @@ function printPurchaseOrderReports(orders) {
function printSalesOrderReports(orders) { function printSalesOrderReports(orders) {
/** /**
* Print SO reports for the provided purchase order(s) * Print SalesOrder reports for the provided purchase order(s)
*/ */
if (orders.length == 0) { if (orders.length == 0) {