mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Function to test if enough parts for a build
This commit is contained in:
parent
dad594dc7a
commit
7c3b1f9bb4
@ -74,6 +74,17 @@ class Build(models.Model):
|
||||
|
||||
return parts
|
||||
|
||||
@property
|
||||
def can_build(self):
|
||||
""" Return true if there are enough parts to supply build
|
||||
"""
|
||||
|
||||
for item in self.required_parts:
|
||||
if item['part'].total_stock < item['quantity']:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@property
|
||||
def is_active(self):
|
||||
""" Is this build active?
|
||||
|
@ -24,6 +24,18 @@
|
||||
<tr>
|
||||
<td>Created</td><td>{{ build.creation_date }}</td>
|
||||
</tr>
|
||||
{% if build.is_active %}
|
||||
<tr>
|
||||
<td>Enough Parts?</td>
|
||||
<td>
|
||||
{% if build.can_build %}
|
||||
Yes
|
||||
{% else %}
|
||||
No
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if batch.completion_date %}
|
||||
<tr>
|
||||
<td>Completed</td><td>{{ build.creation_date }}</td>
|
||||
|
Loading…
Reference in New Issue
Block a user