mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add ability for Company model to count stock sourced from that supplier
This commit is contained in:
parent
1b06cd23af
commit
64a82389a2
@ -7,6 +7,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from django.apps import apps
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -111,6 +112,19 @@ class Company(models.Model):
|
|||||||
""" Return True if this company supplies any parts """
|
""" Return True if this company supplies any parts """
|
||||||
return self.part_count > 0
|
return self.part_count > 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def stock_items(self):
|
||||||
|
""" Return a list of all stock items supplied by this company """
|
||||||
|
stock = apps.get_model('stock', 'StockItem')
|
||||||
|
return stock.objects.filter(supplier_part__supplier=self.id).all()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def stock_count(self):
|
||||||
|
""" Return the number of stock items supplied by this company """
|
||||||
|
stock = apps.get_model('stock', 'StockItem')
|
||||||
|
return stock.objects.filter(supplier_part__supplier=self.id).count()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Contact(models.Model):
|
class Contact(models.Model):
|
||||||
""" A Contact represents a person who works at a particular company.
|
""" A Contact represents a person who works at a particular company.
|
||||||
|
Loading…
Reference in New Issue
Block a user