mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fix migration coverage for orders
This commit is contained in:
parent
10170b5466
commit
a4c6d0e6c5
@ -37,14 +37,14 @@ def build_refs(apps, schema_editor):
|
|||||||
if result and len(result.groups()) == 1:
|
if result and len(result.groups()) == 1:
|
||||||
try:
|
try:
|
||||||
ref = int(result.groups()[0])
|
ref = int(result.groups()[0])
|
||||||
except:
|
except: # pragma: no cover
|
||||||
ref = 0
|
ref = 0
|
||||||
|
|
||||||
order.reference_int = ref
|
order.reference_int = ref
|
||||||
order.save()
|
order.save()
|
||||||
|
|
||||||
|
|
||||||
def unbuild_refs(apps, schema_editor):
|
def unbuild_refs(apps, schema_editor): # pragma: no cover
|
||||||
"""
|
"""
|
||||||
Provided only for reverse migration compatibility
|
Provided only for reverse migration compatibility
|
||||||
"""
|
"""
|
||||||
|
@ -33,7 +33,7 @@ def add_shipment(apps, schema_editor):
|
|||||||
line__order=order
|
line__order=order
|
||||||
)
|
)
|
||||||
|
|
||||||
if allocations.count() == 0 and order.status != SalesOrderStatus.PENDING:
|
if allocations.count() == 0 and order.status != SalesOrderStatus.PENDING: # pragma: no cover
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Create a new Shipment instance against this order
|
# Create a new Shipment instance against this order
|
||||||
@ -41,13 +41,13 @@ def add_shipment(apps, schema_editor):
|
|||||||
order=order,
|
order=order,
|
||||||
)
|
)
|
||||||
|
|
||||||
if order.status == SalesOrderStatus.SHIPPED:
|
if order.status == SalesOrderStatus.SHIPPED: # pragma: no cover
|
||||||
shipment.shipment_date = order.shipment_date
|
shipment.shipment_date = order.shipment_date
|
||||||
|
|
||||||
shipment.save()
|
shipment.save()
|
||||||
|
|
||||||
# Iterate through each allocation associated with this order
|
# Iterate through each allocation associated with this order
|
||||||
for allocation in allocations:
|
for allocation in allocations: # pragma: no cover
|
||||||
allocation.shipment = shipment
|
allocation.shipment = shipment
|
||||||
allocation.save()
|
allocation.save()
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ def add_shipment(apps, schema_editor):
|
|||||||
print(f"\nCreated SalesOrderShipment for {n} SalesOrder instances")
|
print(f"\nCreated SalesOrderShipment for {n} SalesOrder instances")
|
||||||
|
|
||||||
|
|
||||||
def reverse_add_shipment(apps, schema_editor):
|
def reverse_add_shipment(apps, schema_editor): # pragma: no cover
|
||||||
"""
|
"""
|
||||||
Reverse the migration, delete and SalesOrderShipment instances
|
Reverse the migration, delete and SalesOrderShipment instances
|
||||||
"""
|
"""
|
||||||
|
@ -22,7 +22,7 @@ def calculate_shipped_quantity(apps, schema_editor):
|
|||||||
StockItem = apps.get_model('stock', 'stockitem')
|
StockItem = apps.get_model('stock', 'stockitem')
|
||||||
SalesOrderLineItem = apps.get_model('order', 'salesorderlineitem')
|
SalesOrderLineItem = apps.get_model('order', 'salesorderlineitem')
|
||||||
|
|
||||||
for item in SalesOrderLineItem.objects.all():
|
for item in SalesOrderLineItem.objects.all(): # pragma: no cover
|
||||||
|
|
||||||
if item.order.status == SalesOrderStatus.SHIPPED:
|
if item.order.status == SalesOrderStatus.SHIPPED:
|
||||||
item.shipped = item.quantity
|
item.shipped = item.quantity
|
||||||
@ -40,7 +40,7 @@ def calculate_shipped_quantity(apps, schema_editor):
|
|||||||
item.save()
|
item.save()
|
||||||
|
|
||||||
|
|
||||||
def reverse_calculate_shipped_quantity(apps, schema_editor):
|
def reverse_calculate_shipped_quantity(apps, schema_editor): # pragma: no cover
|
||||||
"""
|
"""
|
||||||
Provided only for reverse migration compatibility.
|
Provided only for reverse migration compatibility.
|
||||||
This function does nothing.
|
This function does nothing.
|
||||||
|
Loading…
Reference in New Issue
Block a user