mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-01 17:51:23 +00:00
Receive virtual parts (#11627)
* Handle receive of virtual parts - Update line item quantity - Do not add any stock * Add unit test * Additional unit test * UI form improvements * Add playwright test * Updated playwright tests
This commit is contained in:
@@ -1038,6 +1038,29 @@ class PurchaseOrder(TotalPriceMixin, Order):
|
||||
|
||||
base_part = supplier_part.part
|
||||
|
||||
# Update the line item quantity
|
||||
line.received += quantity
|
||||
line_items_to_update.append(line)
|
||||
|
||||
# Extract optional serial numbers
|
||||
serials = item.get('serials', None)
|
||||
|
||||
if serials and type(serials) is list and len(serials) > 0:
|
||||
serialize = True
|
||||
else:
|
||||
serialize = False
|
||||
serials = [None]
|
||||
|
||||
if base_part.virtual:
|
||||
# Virtual parts are not received into stock, so skip the rest of the loop
|
||||
|
||||
if serialize:
|
||||
raise ValidationError(
|
||||
_('Serial numbers cannot be assigned to virtual parts')
|
||||
)
|
||||
|
||||
continue
|
||||
|
||||
stock_location = item.get('location', location) or line.get_destination()
|
||||
|
||||
# Calculate the received quantity in base part units
|
||||
@@ -1052,15 +1075,6 @@ class PurchaseOrder(TotalPriceMixin, Order):
|
||||
else:
|
||||
purchase_price = None
|
||||
|
||||
# Extract optional serial numbers
|
||||
serials = item.get('serials', None)
|
||||
|
||||
if serials and type(serials) is list and len(serials) > 0:
|
||||
serialize = True
|
||||
else:
|
||||
serialize = False
|
||||
serials = [None]
|
||||
|
||||
# Construct dataset for creating a new StockItem instances
|
||||
stock_data = {
|
||||
'part': supplier_part.part,
|
||||
@@ -1144,10 +1158,6 @@ class PurchaseOrder(TotalPriceMixin, Order):
|
||||
|
||||
bulk_create_items.append(new_item)
|
||||
|
||||
# Update the line item quantity
|
||||
line.received += quantity
|
||||
line_items_to_update.append(line)
|
||||
|
||||
# Bulk create new stock items
|
||||
if len(bulk_create_items) > 0:
|
||||
stock.models.StockItem.objects.bulk_create(bulk_create_items)
|
||||
|
||||
Reference in New Issue
Block a user