diff --git a/InvenTree/order/forms.py b/InvenTree/order/forms.py index 15b9e740d8..87e042f4f3 100644 --- a/InvenTree/order/forms.py +++ b/InvenTree/order/forms.py @@ -8,8 +8,6 @@ from __future__ import unicode_literals from django import forms from django.utils.translation import ugettext_lazy as _ -from mptt.fields import TreeNodeChoiceField - from InvenTree.forms import HelperForm from InvenTree.fields import InvenTreeMoneyField, RoundingDecimalFormField @@ -19,7 +17,6 @@ from common.forms import MatchItemForm import part.models -from stock.models import StockLocation from .models import PurchaseOrder from .models import SalesOrder, SalesOrderLineItem from .models import SalesOrderAllocation diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index 04ded4fbbb..3886bfd3a5 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -329,6 +329,9 @@ class POReceiveSerializer(serializers.Serializer): return data def save(self): + """ + Perform the actual database transaction to receive purchase order items + """ data = self.validated_data @@ -342,10 +345,13 @@ class POReceiveSerializer(serializers.Serializer): with transaction.atomic(): for item in items: + # Select location + loc = item.get('location', None) or item['line_item'].get_destination() or location + try: order.receive_line_item( item['line_item'], - item['location'], + loc, item['quantity'], request.user, status=item['status'], diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index a953324b47..8a5e709926 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -26,7 +26,7 @@ from .models import SalesOrderAllocation from .admin import POLineItemResource from build.models import Build from company.models import Company, SupplierPart # ManufacturerPart -from stock.models import StockItem, StockLocation +from stock.models import StockItem from part.models import Part from common.models import InvenTreeSetting @@ -42,7 +42,7 @@ from InvenTree.helpers import DownloadFile, str2bool from InvenTree.helpers import extract_serial_numbers from InvenTree.views import InvenTreeRoleMixin -from InvenTree.status_codes import PurchaseOrderStatus, StockStatus +from InvenTree.status_codes import PurchaseOrderStatus logger = logging.getLogger("inventree")