2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 03:25:42 +00:00

Add order status field

- Display status field in PurchaseOrder list view
This commit is contained in:
Oliver Walters
2019-06-04 23:09:51 +10:00
parent da53de844a
commit 76a72be926
11 changed files with 112 additions and 12 deletions

View File

@ -17,6 +17,8 @@ from django.urls import reverse
from django.conf import settings
from django.contrib.staticfiles.templatetags.staticfiles import static
from InvenTree.status_codes import OrderStatus
def rename_company_image(instance, filename):
""" Function to rename a company image after upload
@ -128,6 +130,26 @@ class Company(models.Model):
stock = apps.get_model('stock', 'StockItem')
return stock.objects.filter(supplier_part__supplier=self.id).count()
def outstanding_purchase_orders(self):
""" Return purchase orders which are 'outstanding' """
return self.purchase_orders.filter(status__in=[
OrderStatus.PENDING,
OrderStatus.PLACED
])
def complete_purchase_orders(self):
return self.purchase_orders.filter(status=OrderStatus.COMPLETE)
def failed_purchase_orders(self):
""" Return any purchase orders which were not successful """
return self.purchase_orders.filter(status__in=[
OrderStatus.CANCELLED,
OrderStatus.LOST,
OrderStatus.RETURNED
])
class Contact(models.Model):
""" A Contact represents a person who works at a particular company.