mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Auto-select a purchase order when ordering parts
This commit is contained in:
parent
0199760e1c
commit
26f0338f1d
@ -766,6 +766,7 @@ class OrderParts(AjaxView):
|
|||||||
|
|
||||||
for supplier in self.suppliers:
|
for supplier in self.suppliers:
|
||||||
supplier.order_items = []
|
supplier.order_items = []
|
||||||
|
|
||||||
suppliers[supplier.name] = supplier
|
suppliers[supplier.name] = supplier
|
||||||
|
|
||||||
for part in self.parts:
|
for part in self.parts:
|
||||||
@ -778,7 +779,15 @@ class OrderParts(AjaxView):
|
|||||||
|
|
||||||
if supplier.name not in suppliers:
|
if supplier.name not in suppliers:
|
||||||
supplier.order_items = []
|
supplier.order_items = []
|
||||||
supplier.selected_purchase_order = None
|
|
||||||
|
# Attempt to auto-select a purchase order
|
||||||
|
orders = PurchaseOrder.objects.filter(supplier=supplier, status__in=PurchaseOrderStatus.OPEN)
|
||||||
|
|
||||||
|
if orders.count() == 1:
|
||||||
|
supplier.selected_purchase_order = orders.first().id
|
||||||
|
else:
|
||||||
|
supplier.selected_purchase_order = None
|
||||||
|
|
||||||
suppliers[supplier.name] = supplier
|
suppliers[supplier.name] = supplier
|
||||||
|
|
||||||
suppliers[supplier.name].order_items.append(part)
|
suppliers[supplier.name].order_items.append(part)
|
||||||
|
Loading…
Reference in New Issue
Block a user