diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index f72668f9f0..214f1cd605 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -637,7 +637,7 @@ class SupplierPart(models.Model): get_price = common.models.get_price 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. """ diff --git a/InvenTree/order/admin.py b/InvenTree/order/admin.py index adfbcbfa75..0de28d5668 100644 --- a/InvenTree/order/admin.py +++ b/InvenTree/order/admin.py @@ -92,8 +92,8 @@ class SalesOrderAdmin(ImportExportModelAdmin): autocomplete_fields = ('customer',) -class POLineItemResource(ModelResource): - """ Class for managing import / export of POLineItem data """ +class PurchaseOrderLineItemResource(ModelResource): + """ Class for managing import / export of PurchaseOrderLineItem data """ part_name = Field(attribute='part__part__name', readonly=True) @@ -110,16 +110,16 @@ class POLineItemResource(ModelResource): clean_model_instances = True -class POExtraLineResource(ModelResource): - """ Class for managing import / export of POExtraLine data """ +class PurchaseOrderExtraLineResource(ModelResource): + """ Class for managing import / export of PurchaseOrderExtraLine data """ class Meta(GeneralExtraLineMeta): 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) @@ -148,8 +148,8 @@ class SOLineItemResource(ModelResource): clean_model_instances = True -class SOExtraLineResource(ModelResource): - """ Class for managing import / export of SOExtraLine data """ +class SalesOrderExtraLineResource(ModelResource): + """ Class for managing import / export of SalesOrderExtraLine data """ class Meta(GeneralExtraLineMeta): model = SalesOrderExtraLine @@ -157,7 +157,7 @@ class SOExtraLineResource(ModelResource): class PurchaseOrderLineItemAdmin(ImportExportModelAdmin): - resource_class = POLineItemResource + resource_class = PurchaseOrderLineItemResource list_display = ( 'order', @@ -173,12 +173,12 @@ class PurchaseOrderLineItemAdmin(ImportExportModelAdmin): class PurchaseOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin): - resource_class = POExtraLineResource + resource_class = PurchaseOrderExtraLineResource class SalesOrderLineItemAdmin(ImportExportModelAdmin): - resource_class = SOLineItemResource + resource_class = SalesOrderLineItemResource list_display = ( 'order', @@ -199,7 +199,7 @@ class SalesOrderLineItemAdmin(ImportExportModelAdmin): class SalesOrderExtraLineAdmin(GeneralExtraLineAdmin, ImportExportModelAdmin): - resource_class = SOExtraLineResource + resource_class = SalesOrderExtraLineResource class SalesOrderShipmentAdmin(ImportExportModelAdmin): diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py index bd290f5bd4..0b0fe3185a 100644 --- a/InvenTree/order/api.py +++ b/InvenTree/order/api.py @@ -20,7 +20,7 @@ from InvenTree.helpers import str2bool, DownloadFile from InvenTree.api import AttachmentMixin from InvenTree.status_codes import PurchaseOrderStatus, SalesOrderStatus -from order.admin import POLineItemResource +from order.admin import PurchaseOrderLineItemResource import order.models as models import order.serializers as serializers 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') @@ -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 - - GET: Return list of PO objects (with filters) + - GET: Return list of PurchaseOrder objects (with filters) - POST: Create a new PurchaseOrder object """ queryset = models.PurchaseOrder.objects.all() - serializer_class = serializers.POSerializer - filterset_class = POFilter + serializer_class = serializers.PurchaseOrderSerializer + filterset_class = PurchaseOrderFilter def create(self, request, *args, **kwargs): """ @@ -156,7 +156,7 @@ class POList(generics.ListCreateAPIView): 'lines', ) - queryset = serializers.POSerializer.annotate_queryset(queryset) + queryset = serializers.PurchaseOrderSerializer.annotate_queryset(queryset) return queryset @@ -254,11 +254,11 @@ class POList(generics.ListCreateAPIView): ordering = '-creation_date' -class PODetail(generics.RetrieveUpdateDestroyAPIView): +class PurchaseOrderDetail(generics.RetrieveUpdateDestroyAPIView): """ API endpoint for detail view of a PurchaseOrder object """ queryset = models.PurchaseOrder.objects.all() - serializer_class = serializers.POSerializer + serializer_class = serializers.PurchaseOrderSerializer def get_serializer(self, *args, **kwargs): @@ -281,12 +281,12 @@ class PODetail(generics.RetrieveUpdateDestroyAPIView): 'lines', ) - queryset = serializers.POSerializer.annotate_queryset(queryset) + queryset = serializers.PurchaseOrderSerializer.annotate_queryset(queryset) return queryset -class POReceive(generics.CreateAPIView): +class PurchaseOrderReceive(generics.CreateAPIView): """ API endpoint to receive stock items against a purchase order. @@ -301,7 +301,7 @@ class POReceive(generics.CreateAPIView): queryset = models.PurchaseOrderLineItem.objects.none() - serializer_class = serializers.POReceiveSerializer + serializer_class = serializers.PurchaseOrderReceiveSerializer def get_serializer_context(self): @@ -318,9 +318,9 @@ class POReceive(generics.CreateAPIView): 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: @@ -370,22 +370,22 @@ class POLineItemFilter(rest_filters.FilterSet): return queryset -class POLineItemList(generics.ListCreateAPIView): - """ API endpoint for accessing a list of POLineItem objects +class PurchaseOrderLineItemList(generics.ListCreateAPIView): + """ 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 """ queryset = models.PurchaseOrderLineItem.objects.all() - serializer_class = serializers.POLineItemSerializer - filterset_class = POLineItemFilter + serializer_class = serializers.PurchaseOrderLineItemSerializer + filterset_class = PurchaseOrderLineItemFilter def get_queryset(self, *args, **kwargs): queryset = super().get_queryset(*args, **kwargs) - queryset = serializers.POLineItemSerializer.annotate_queryset(queryset) + queryset = serializers.PurchaseOrderLineItemSerializer.annotate_queryset(queryset) return queryset @@ -434,7 +434,7 @@ class POLineItemList(generics.ListCreateAPIView): export_format = str(export_format).strip().lower() if export_format in ['csv', 'tsv', 'xls', 'xlsx']: - dataset = POLineItemResource().export(queryset=queryset) + dataset = PurchaseOrderLineItemResource().export(queryset=queryset) 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 """ queryset = models.PurchaseOrderLineItem.objects.all() - serializer_class = serializers.POLineItemSerializer + serializer_class = serializers.PurchaseOrderLineItemSerializer def get_queryset(self): queryset = super().get_queryset() - queryset = serializers.POLineItemSerializer.annotate_queryset(queryset) + queryset = serializers.PurchaseOrderLineItemSerializer.annotate_queryset(queryset) return queryset -class POExtraLineList(GeneralExtraLineList, generics.ListCreateAPIView): +class PurchaseOrderExtraLineList(GeneralExtraLineList, generics.ListCreateAPIView): """ API endpoint for accessing a list of PurchaseOrderExtraLine objects. """ 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 """ 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) """ queryset = models.SalesOrderAttachment.objects.all() - serializer_class = serializers.SOAttachmentSerializer + serializer_class = serializers.SalesOrderAttachmentSerializer filter_backends = [ 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 """ 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. - - GET: Return list of SO objects (with filters) + - GET: Return list of SalesOrder objects (with filters) - POST: Create a new SalesOrder """ @@ -684,7 +684,7 @@ class SOList(generics.ListCreateAPIView): ordering = '-creation_date' -class SODetail(generics.RetrieveUpdateDestroyAPIView): +class SalesOrderDetail(generics.RetrieveUpdateDestroyAPIView): """ API endpoint for detail view of a SalesOrder object. """ @@ -714,9 +714,9 @@ class SODetail(generics.RetrieveUpdateDestroyAPIView): return queryset -class SOLineItemFilter(rest_filters.FilterSet): +class SalesOrderLineItemFilter(rest_filters.FilterSet): """ - Custom filters for SOLineItemList endpoint + Custom filters for SalesOrderLineItemList endpoint """ class Meta: @@ -747,14 +747,14 @@ class SOLineItemFilter(rest_filters.FilterSet): return queryset -class SOLineItemList(generics.ListCreateAPIView): +class SalesOrderLineItemList(generics.ListCreateAPIView): """ API endpoint for accessing a list of SalesOrderLineItem objects. """ queryset = models.SalesOrderLineItem.objects.all() - serializer_class = serializers.SOLineItemSerializer - filterset_class = SOLineItemFilter + serializer_class = serializers.SalesOrderLineItemSerializer + filterset_class = SalesOrderLineItemFilter 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. """ 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 """ 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 """ queryset = models.SalesOrderLineItem.objects.all() - serializer_class = serializers.SOLineItemSerializer + serializer_class = serializers.SalesOrderLineItemSerializer class SalesOrderComplete(generics.CreateAPIView): @@ -863,7 +863,7 @@ class SalesOrderAllocateSerials(generics.CreateAPIView): """ queryset = models.SalesOrder.objects.none() - serializer_class = serializers.SOSerialAllocationSerializer + serializer_class = serializers.SalesOrderSerialAllocationSerializer def get_serializer_context(self): @@ -885,11 +885,11 @@ class SalesOrderAllocate(generics.CreateAPIView): API endpoint to allocate stock items against a SalesOrder - The SalesOrder is specified in the URL - - See the SOShipmentAllocationSerializer class + - See the SalesOrderShipmentAllocationSerializer class """ queryset = models.SalesOrder.objects.none() - serializer_class = serializers.SOShipmentAllocationSerializer + serializer_class = serializers.SalesOrderShipmentAllocationSerializer def get_serializer_context(self): @@ -906,7 +906,7 @@ class SalesOrderAllocate(generics.CreateAPIView): return ctx -class SOAllocationDetail(generics.RetrieveUpdateDestroyAPIView): +class SalesOrderAllocationDetail(generics.RetrieveUpdateDestroyAPIView): """ API endpoint for detali view of a SalesOrderAllocation object """ @@ -915,7 +915,7 @@ class SOAllocationDetail(generics.RetrieveUpdateDestroyAPIView): serializer_class = serializers.SalesOrderAllocationSerializer -class SOAllocationList(generics.ListAPIView): +class SalesOrderAllocationList(generics.ListAPIView): """ 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') @@ -1018,21 +1018,21 @@ class SOShipmentFilter(rest_filters.FilterSet): ] -class SOShipmentList(generics.ListCreateAPIView): +class SalesOrderShipmentList(generics.ListCreateAPIView): """ API list endpoint for SalesOrderShipment model """ queryset = models.SalesOrderShipment.objects.all() serializer_class = serializers.SalesOrderShipmentSerializer - filterset_class = SOShipmentFilter + filterset_class = SalesOrderShipmentFilter filter_backends = [ rest_filters.DjangoFilterBackend, ] -class SOShipmentDetail(generics.RetrieveUpdateDestroyAPIView): +class SalesOrderShipmentDetail(generics.RetrieveUpdateDestroyAPIView): """ API detail endpooint for SalesOrderShipment model """ @@ -1041,7 +1041,7 @@ class SOShipmentDetail(generics.RetrieveUpdateDestroyAPIView): serializer_class = serializers.SalesOrderShipmentSerializer -class SOShipmentComplete(generics.CreateAPIView): +class SalesOrderShipmentComplete(generics.CreateAPIView): """ API endpoint for completing (shipping) a SalesOrderShipment """ @@ -1067,13 +1067,13 @@ class SOShipmentComplete(generics.CreateAPIView): return ctx -class POAttachmentList(generics.ListCreateAPIView, AttachmentMixin): +class PurchaseOrderAttachmentList(generics.ListCreateAPIView, AttachmentMixin): """ API endpoint for listing (and creating) a PurchaseOrderAttachment (file upload) """ queryset = models.PurchaseOrderAttachment.objects.all() - serializer_class = serializers.POAttachmentSerializer + serializer_class = serializers.PurchaseOrderAttachmentSerializer filter_backends = [ 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 """ queryset = models.PurchaseOrderAttachment.objects.all() - serializer_class = serializers.POAttachmentSerializer + serializer_class = serializers.PurchaseOrderAttachmentSerializer order_api_urls = [ @@ -1100,45 +1100,45 @@ order_api_urls = [ # Purchase order attachments url(r'attachment/', include([ - url(r'^(?P\d+)/$', POAttachmentDetail.as_view(), name='api-po-attachment-detail'), - url(r'^.*$', POAttachmentList.as_view(), name='api-po-attachment-list'), + url(r'^(?P\d+)/$', PurchaseOrderAttachmentDetail.as_view(), name='api-po-attachment-detail'), + url(r'^.*$', PurchaseOrderAttachmentList.as_view(), name='api-po-attachment-list'), ])), # Individual purchase order detail URLs url(r'^(?P\d+)/', include([ - url(r'^receive/', POReceive.as_view(), name='api-po-receive'), - url(r'.*$', PODetail.as_view(), name='api-po-detail'), + url(r'^receive/', PurchaseOrderReceive.as_view(), name='api-po-receive'), + url(r'.*$', PurchaseOrderDetail.as_view(), name='api-po-detail'), ])), # 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 url(r'^po-line/', include([ - url(r'^(?P\d+)/$', POLineItemDetail.as_view(), name='api-po-line-detail'), - url(r'^.*$', POLineItemList.as_view(), name='api-po-line-list'), + url(r'^(?P\d+)/$', PurchaseOrderLineItemDetail.as_view(), name='api-po-line-detail'), + url(r'^.*$', PurchaseOrderLineItemList.as_view(), name='api-po-line-list'), ])), # API endpoints for purchase order extra line url(r'^po-extra-line/', include([ - url(r'^(?P\d+)/$', POExtraLineDetail.as_view(), name='api-po-extra-line-detail'), - url(r'^$', POExtraLineList.as_view(), name='api-po-extra-line-list'), + url(r'^(?P\d+)/$', PurchaseOrderExtraLineDetail.as_view(), name='api-po-extra-line-detail'), + url(r'^$', PurchaseOrderExtraLineList.as_view(), name='api-po-extra-line-list'), ])), # API endpoints for sales ordesr url(r'^so/', include([ url(r'attachment/', include([ - url(r'^(?P\d+)/$', SOAttachmentDetail.as_view(), name='api-so-attachment-detail'), - url(r'^.*$', SOAttachmentList.as_view(), name='api-so-attachment-list'), + url(r'^(?P\d+)/$', SalesOrderAttachmentDetail.as_view(), name='api-so-attachment-detail'), + url(r'^.*$', SalesOrderAttachmentList.as_view(), name='api-so-attachment-list'), ])), url(r'^shipment/', include([ url(r'^(?P\d+)/', include([ - url(r'^ship/$', SOShipmentComplete.as_view(), name='api-so-shipment-ship'), - url(r'^.*$', SOShipmentDetail.as_view(), name='api-so-shipment-detail'), + url(r'^ship/$', SalesOrderShipmentComplete.as_view(), name='api-so-shipment-ship'), + 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 @@ -1146,28 +1146,28 @@ order_api_urls = [ url(r'^complete/', SalesOrderComplete.as_view(), name='api-so-complete'), url(r'^allocate/', SalesOrderAllocate.as_view(), name='api-so-allocate'), 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 - 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 url(r'^so-line/', include([ - url(r'^(?P\d+)/$', SOLineItemDetail.as_view(), name='api-so-line-detail'), - url(r'^$', SOLineItemList.as_view(), name='api-so-line-list'), + url(r'^(?P\d+)/$', SalesOrderLineItemDetail.as_view(), name='api-so-line-detail'), + url(r'^$', SalesOrderLineItemList.as_view(), name='api-so-line-list'), ])), # API endpoints for sales order extra line url(r'^so-extra-line/', include([ - url(r'^(?P\d+)/$', SOExtraLineDetail.as_view(), name='api-so-extra-line-detail'), - url(r'^$', SOExtraLineList.as_view(), name='api-so-extra-line-list'), + url(r'^(?P\d+)/$', SalesOrderExtraLineDetail.as_view(), name='api-so-extra-line-detail'), + url(r'^$', SalesOrderExtraLineList.as_view(), name='api-so-extra-line-list'), ])), # API endpoints for sales order allocations url(r'^so-allocation/', include([ - url(r'^(?P\d+)/$', SOAllocationDetail.as_view(), name='api-so-allocation-detail'), - url(r'^.*$', SOAllocationList.as_view(), name='api-so-allocation-list'), + url(r'^(?P\d+)/$', SalesOrderAllocationDetail.as_view(), name='api-so-allocation-detail'), + url(r'^.*$', SalesOrderAllocationList.as_view(), name='api-so-allocation-list'), ])), ] diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index d639de4b56..057f3b34b6 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -309,7 +309,7 @@ class PurchaseOrder(Order): raise ValidationError({'supplier': _("Part supplier must match PO supplier")}) 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) if matches.count() > 0: @@ -424,7 +424,7 @@ class PurchaseOrder(Order): @transaction.atomic 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 diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index 4688fa34a6..bf695d36c3 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -96,7 +96,7 @@ class AbstractExtraLineMeta: ] -class POSerializer(AbstractOrderSerializer, ReferenceIndexingSerializerMixin, InvenTreeModelSerializer): +class PurchaseOrderSerializer(AbstractOrderSerializer, ReferenceIndexingSerializerMixin, InvenTreeModelSerializer): """ Serializer for a PurchaseOrder object """ def __init__(self, *args, **kwargs): @@ -178,7 +178,7 @@ class POSerializer(AbstractOrderSerializer, ReferenceIndexingSerializerMixin, In ] -class POLineItemSerializer(InvenTreeModelSerializer): +class PurchaseOrderLineItemSerializer(InvenTreeModelSerializer): @staticmethod def annotate_queryset(queryset): @@ -245,7 +245,7 @@ class POLineItemSerializer(InvenTreeModelSerializer): 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: model = order.models.PurchaseOrderLineItem @@ -272,16 +272,16 @@ class POLineItemSerializer(InvenTreeModelSerializer): ] -class POExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer): +class PurchaseOrderExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer): """ 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): 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 """ @@ -411,12 +411,12 @@ class POLineItemReceiveSerializer(serializers.Serializer): return data -class POReceiveSerializer(serializers.Serializer): +class PurchaseOrderReceiveSerializer(serializers.Serializer): """ Serializer for receiving items against a purchase order """ - items = POLineItemReceiveSerializer(many=True) + items = PurchaseOrderLineItemReceiveSerializer(many=True) location = serializers.PrimaryKeyRelatedField( 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 """ @@ -681,7 +681,7 @@ class SalesOrderAllocationSerializer(InvenTreeModelSerializer): ] -class SOLineItemSerializer(InvenTreeModelSerializer): +class SalesOrderLineItemSerializer(InvenTreeModelSerializer): """ Serializer for a SalesOrderLineItem object """ @staticmethod @@ -931,7 +931,7 @@ class SalesOrderCompleteSerializer(serializers.Serializer): order.complete_order(user) -class SOSerialAllocationSerializer(serializers.Serializer): +class SalesOrderSerialAllocationSerializer(serializers.Serializer): """ 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 """ @@ -1168,7 +1168,7 @@ class SOShipmentAllocationSerializer(serializers.Serializer): ) -class SOExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer): +class SalesOrderExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer): """ Serializer for a SalesOrderExtraLine object """ order_detail = SalesOrderSerializer(source='order', many=False, read_only=True) @@ -1177,7 +1177,7 @@ class SOExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerialize model = order.models.SalesOrderExtraLine -class SOAttachmentSerializer(InvenTreeAttachmentSerializer): +class SalesOrderAttachmentSerializer(InvenTreeAttachmentSerializer): """ Serializers for the SalesOrderAttachment model """ diff --git a/InvenTree/order/test_api.py b/InvenTree/order/test_api.py index 8d5d91f0fb..d3e405e5fa 100644 --- a/InvenTree/order/test_api.py +++ b/InvenTree/order/test_api.py @@ -63,7 +63,7 @@ class PurchaseOrderTest(OrderTest): def test_po_list(self): - # List *ALL* PO items + # List *ALL* PurchaseOrder items self.filter({}, 7) # Filter by supplier @@ -175,7 +175,7 @@ class PurchaseOrderTest(OrderTest): 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( url, { @@ -493,7 +493,7 @@ class PurchaseOrderReceiveTest(OrderTest): 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.save() diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index c89d2a77b1..69d42b9594 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -20,7 +20,7 @@ from decimal import Decimal, InvalidOperation from .models import PurchaseOrder, PurchaseOrderLineItem from .models import SalesOrder, SalesOrderLineItem -from .admin import POLineItemResource, SOLineItemResource +from .admin import PurchaseOrderLineItemResource, SalesOrderLineItemResource from build.models import Build from company.models import Company, SupplierPart # ManufacturerPart from stock.models import StockItem @@ -410,7 +410,7 @@ class SalesOrderExport(AjaxView): 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) @@ -441,7 +441,7 @@ class PurchaseOrderExport(AjaxView): fmt=export_format ) - dataset = POLineItemResource().export(queryset=order.lines.all()) + dataset = PurchaseOrderLineItemResource().export(queryset=order.lines.all()) filedata = dataset.export(format=export_format) @@ -491,7 +491,7 @@ class OrderParts(AjaxView): return data 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. Crucially, get_parts() must be called before get_suppliers() """ diff --git a/InvenTree/report/api.py b/InvenTree/report/api.py index c7d2b15e4d..0484cfbc06 100644 --- a/InvenTree/report/api.py +++ b/InvenTree/report/api.py @@ -31,8 +31,8 @@ from .models import SalesOrderReport from .serializers import TestReportSerializer from .serializers import BuildReportSerializer from .serializers import BOMReportSerializer -from .serializers import POReportSerializer -from .serializers import SOReportSerializer +from .serializers import PurchaseOrderReportSerializer +from .serializers import SalesOrderReportSerializer class ReportListView(generics.ListAPIView): @@ -561,12 +561,12 @@ class BuildReportPrint(generics.RetrieveAPIView, BuildReportMixin, ReportPrintMi return self.print(request, builds) -class POReportList(ReportListView, OrderReportMixin): +class PurchaseOrderReportList(ReportListView, OrderReportMixin): OrderModel = order.models.PurchaseOrder queryset = PurchaseOrderReport.objects.all() - serializer_class = POReportSerializer + serializer_class = PurchaseOrderReportSerializer def filter_queryset(self, queryset): @@ -618,16 +618,16 @@ class POReportList(ReportListView, OrderReportMixin): return queryset -class POReportDetail(generics.RetrieveUpdateDestroyAPIView): +class PurchaseOrderReportDetail(generics.RetrieveUpdateDestroyAPIView): """ API endpoint for a single PurchaseOrderReport object """ 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 """ @@ -635,7 +635,7 @@ class POReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin OrderModel = order.models.PurchaseOrder queryset = PurchaseOrderReport.objects.all() - serializer_class = POReportSerializer + serializer_class = PurchaseOrderReportSerializer def get(self, request, *args, **kwargs): @@ -644,12 +644,12 @@ class POReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin return self.print(request, orders) -class SOReportList(ReportListView, OrderReportMixin): +class SalesOrderReportList(ReportListView, OrderReportMixin): OrderModel = order.models.SalesOrder queryset = SalesOrderReport.objects.all() - serializer_class = SOReportSerializer + serializer_class = SalesOrderReportSerializer def filter_queryset(self, queryset): @@ -701,16 +701,16 @@ class SOReportList(ReportListView, OrderReportMixin): return queryset -class SOReportDetail(generics.RetrieveUpdateDestroyAPIView): +class SalesOrderReportDetail(generics.RetrieveUpdateDestroyAPIView): """ API endpoint for a single SalesOrderReport object """ 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 """ @@ -718,7 +718,7 @@ class SOReportPrint(generics.RetrieveAPIView, OrderReportMixin, ReportPrintMixin OrderModel = order.models.SalesOrder queryset = SalesOrderReport.objects.all() - serializer_class = SOReportSerializer + serializer_class = SalesOrderReportSerializer def get(self, request, *args, **kwargs): @@ -733,23 +733,23 @@ report_api_urls = [ url(r'po/', include([ # Detail views url(r'^(?P\d+)/', include([ - url(r'print/', POReportPrint.as_view(), name='api-po-report-print'), - url(r'^$', POReportDetail.as_view(), name='api-po-report-detail'), + url(r'print/', PurchaseOrderReportPrint.as_view(), name='api-po-report-print'), + url(r'^$', PurchaseOrderReportDetail.as_view(), name='api-po-report-detail'), ])), # 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 url(r'so/', include([ # Detail views url(r'^(?P\d+)/', include([ - url(r'print/', SOReportPrint.as_view(), name='api-so-report-print'), - url(r'^$', SOReportDetail.as_view(), name='api-so-report-detail'), + url(r'print/', SalesOrderReportPrint.as_view(), name='api-so-report-print'), + 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 diff --git a/InvenTree/report/serializers.py b/InvenTree/report/serializers.py index fa7de1a3ea..6e3e36df18 100644 --- a/InvenTree/report/serializers.py +++ b/InvenTree/report/serializers.py @@ -58,7 +58,7 @@ class BOMReportSerializer(InvenTreeModelSerializer): ] -class POReportSerializer(InvenTreeModelSerializer): +class PurchaseOrderReportSerializer(InvenTreeModelSerializer): template = InvenTreeAttachmentSerializerField(required=True) @@ -74,7 +74,7 @@ class POReportSerializer(InvenTreeModelSerializer): ] -class SOReportSerializer(InvenTreeModelSerializer): +class SalesOrderReportSerializer(InvenTreeModelSerializer): template = InvenTreeAttachmentSerializerField(required=True) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 34563b38d7..1abbb84842 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -36,7 +36,7 @@ from InvenTree.filters import InvenTreeOrderingFilter from order.models import PurchaseOrder 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.serializers import PartBriefSerializer @@ -1220,7 +1220,7 @@ class StockTrackingList(generics.ListAPIView): if 'purchaseorder' in deltas: try: order = PurchaseOrder.objects.get(pk=deltas['purchaseorder']) - serializer = POSerializer(order) + serializer = PurchaseOrderSerializer(order) deltas['purchaseorder_detail'] = serializer.data except: pass diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index f0e6f12acf..fea760ca5c 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -276,7 +276,7 @@ function createPurchaseOrder(options={}) { if (options.onSuccess) { options.onSuccess(data); } 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}/`; } }, @@ -528,7 +528,7 @@ function newPurchaseOrderFromOrderWizard(e) { /** * Receive stock items against a PurchaseOrder - * Uses the POReceive API endpoint + * Uses the PurchaseOrderReceive API endpoint * * arguments: * - order_id, ID / PK for the PurchaseOrder instance diff --git a/InvenTree/templates/js/translated/report.js b/InvenTree/templates/js/translated/report.js index 4f887f2275..49afbcb7ea 100644 --- a/InvenTree/templates/js/translated/report.js +++ b/InvenTree/templates/js/translated/report.js @@ -271,7 +271,7 @@ function printBomReports(parts) { 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) { @@ -325,7 +325,7 @@ function printPurchaseOrderReports(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) {