From ecf70b6d4dd142795b7effbbb03ab5244de3a44b Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 2 Dec 2021 23:58:02 +1100 Subject: [PATCH] Some PEP fixes --- InvenTree/order/models.py | 7 +++---- InvenTree/order/serializers.py | 8 +++++--- InvenTree/order/test_migrations.py | 2 +- InvenTree/order/test_sales_order.py | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 8c21c311f1..b2cca685d9 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -812,7 +812,7 @@ class PurchaseOrderLineItem(OrderLineItem): def get_destination(self): """ Show where the line item is or should be placed - + NOTE: If a line item gets split when recieved, only an arbitrary stock items location will be reported as the location for the entire line. @@ -993,7 +993,7 @@ class SalesOrderShipment(models.Model): if self.shipment_date: # Shipment has already been sent! raise ValidationError(_("Shipment has already been sent")) - + if self.allocations.count() == 0: raise ValidationError(_("Shipment has no allocated stock items")) @@ -1014,11 +1014,10 @@ class SalesOrderShipment(models.Model): # Iterate through each stock item assigned to this shipment for allocation in allocations: - # Mark the allocation as "complete" allocation.complete_allocation(user) - # Update the "shipment" date + # Update the "shipment" date self.shipment_date = datetime.now() self.shipped_by = user diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index 3b33d4a16f..b336042684 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -11,6 +11,7 @@ from django.core.exceptions import ValidationError as DjangoValidationError from django.db import models, transaction from django.db.models import Case, When, Value from django.db.models import BooleanField, ExpressionWrapper, F +from InvenTree.InvenTree.status_codes import SalesOrderStatus from rest_framework import serializers from rest_framework.serializers import ValidationError @@ -653,7 +654,7 @@ class SalesOrderShipmentCompleteSerializer(serializers.ModelSerializer): return data = self.validated_data - + request = self.context['request'] user = request.user @@ -748,7 +749,9 @@ class SalesOrderCompleteSerializer(serializers.Serializer): order = self.context['order'] data = self.validated_data - + # Mark this order as complete! + order.status = SalesOrderStatus.SHIPPED + order.save() class SOShipmentAllocationSerializer(serializers.Serializer): @@ -816,7 +819,6 @@ class SOShipmentAllocationSerializer(serializers.Serializer): with transaction.atomic(): for entry in items: - # Create a new SalesOrderAllocation order.models.SalesOrderAllocation.objects.create( line=entry.get('line_item'), diff --git a/InvenTree/order/test_migrations.py b/InvenTree/order/test_migrations.py index d62449613e..d8f3a655ca 100644 --- a/InvenTree/order/test_migrations.py +++ b/InvenTree/order/test_migrations.py @@ -111,7 +111,7 @@ class TestShipmentMigration(MigratorTestCase): # The "shipment" model does not exist yet with self.assertRaises(LookupError): self.old_state.apps.get_model('order', 'salesordershipment') - + def test_shipment_creation(self): """ Check that a SalesOrderShipment has been created diff --git a/InvenTree/order/test_sales_order.py b/InvenTree/order/test_sales_order.py index 76f9275dac..40fab98349 100644 --- a/InvenTree/order/test_sales_order.py +++ b/InvenTree/order/test_sales_order.py @@ -10,7 +10,7 @@ from company.models import Company from InvenTree import status_codes as status -from order.models import SalesOrder, SalesOrderLineItem, SalesOrderShipment, SalesOrderAllocation +from order.models import SalesOrder, SalesOrderLineItem, SalesOrderAllocation from part.models import Part