2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-10 05:40:55 +00:00

List purchase orders for a given part

This commit is contained in:
Oliver Walters
2019-06-05 21:47:22 +10:00
parent 9b2b2841d9
commit 67248ec4dd
11 changed files with 103 additions and 20 deletions

View File

@@ -794,6 +794,18 @@ class Part(models.Model):
return n
def purchase_orders(self):
""" Return a list of purchase orders which reference this part """
orders = []
for part in self.supplier_parts.all().prefetch_related('purchase_order_line_items'):
for order in part.purchase_orders():
if order not in orders:
orders.append(order)
return orders
def attach_file(instance, filename):
""" Function for storing a file for a PartAttachment