PEP fixes

This commit is contained in:
Oliver 2021-10-05 16:10:00 +11:00
parent dd4428464d
commit 1ea9b6f4cf
3 changed files with 9 additions and 6 deletions

View File

@ -8,8 +8,6 @@ from __future__ import unicode_literals
from django import forms from django import forms
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from mptt.fields import TreeNodeChoiceField
from InvenTree.forms import HelperForm from InvenTree.forms import HelperForm
from InvenTree.fields import InvenTreeMoneyField, RoundingDecimalFormField from InvenTree.fields import InvenTreeMoneyField, RoundingDecimalFormField
@ -19,7 +17,6 @@ from common.forms import MatchItemForm
import part.models import part.models
from stock.models import StockLocation
from .models import PurchaseOrder from .models import PurchaseOrder
from .models import SalesOrder, SalesOrderLineItem from .models import SalesOrder, SalesOrderLineItem
from .models import SalesOrderAllocation from .models import SalesOrderAllocation

View File

@ -329,6 +329,9 @@ class POReceiveSerializer(serializers.Serializer):
return data return data
def save(self): def save(self):
"""
Perform the actual database transaction to receive purchase order items
"""
data = self.validated_data data = self.validated_data
@ -342,10 +345,13 @@ class POReceiveSerializer(serializers.Serializer):
with transaction.atomic(): with transaction.atomic():
for item in items: for item in items:
# Select location
loc = item.get('location', None) or item['line_item'].get_destination() or location
try: try:
order.receive_line_item( order.receive_line_item(
item['line_item'], item['line_item'],
item['location'], loc,
item['quantity'], item['quantity'],
request.user, request.user,
status=item['status'], status=item['status'],

View File

@ -26,7 +26,7 @@ from .models import SalesOrderAllocation
from .admin import POLineItemResource from .admin import POLineItemResource
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, StockLocation from stock.models import StockItem
from part.models import Part from part.models import Part
from common.models import InvenTreeSetting from common.models import InvenTreeSetting
@ -42,7 +42,7 @@ from InvenTree.helpers import DownloadFile, str2bool
from InvenTree.helpers import extract_serial_numbers from InvenTree.helpers import extract_serial_numbers
from InvenTree.views import InvenTreeRoleMixin from InvenTree.views import InvenTreeRoleMixin
from InvenTree.status_codes import PurchaseOrderStatus, StockStatus from InvenTree.status_codes import PurchaseOrderStatus
logger = logging.getLogger("inventree") logger = logging.getLogger("inventree")