Function to test if enough parts for a build

This commit is contained in:
Oliver committed 2018-05-01 09:00:09 +10:00
1 parent dad594dc7a
commit 7c3b1f9bb4
2 files changed
+23

No files matched your search

+11
View File
@@ -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>