mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-03 13:58:47 +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
|
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
|
@property
|
||||||
def is_active(self):
|
def is_active(self):
|
||||||
""" Is this build active?
|
""" Is this build active?
|
||||||
|
@ -24,6 +24,18 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Created</td><td>{{ build.creation_date }}</td>
|
<td>Created</td><td>{{ build.creation_date }}</td>
|
||||||
</tr>
|
</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 %}
|
{% if batch.completion_date %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>Completed</td><td>{{ build.creation_date }}</td>
|
<td>Completed</td><td>{{ build.creation_date }}</td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user