mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
Skeleton code for Build cancel() and complete() functions
- BuildComplete view
This commit is contained in:
@ -76,6 +76,23 @@ class Build(models.Model):
|
||||
notes = models.TextField(blank=True)
|
||||
""" Notes attached to each build output """
|
||||
|
||||
def cancelBuild(self):
|
||||
""" Mark the Build as CANCELLED
|
||||
|
||||
- Delete any pending BuildItem objects (but do not remove items from stock)
|
||||
"""
|
||||
print("cancelled!")
|
||||
|
||||
|
||||
def completeBuild(self):
|
||||
""" Mark the Build as COMPLETE
|
||||
|
||||
- Takes allocated items from stock
|
||||
- Delete pending BuildItem objects
|
||||
"""
|
||||
|
||||
print("complete!!!!")
|
||||
|
||||
@property
|
||||
def required_parts(self):
|
||||
""" Returns a dict of parts required to build this part (BOM) """
|
||||
|
@ -12,6 +12,10 @@
|
||||
<table class='table table-striped' id='build-table'>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
<button class='btn btn-warning' type='button' id='complete-build'>Complete Build</button>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_load %}
|
||||
@ -32,4 +36,14 @@
|
||||
}
|
||||
);
|
||||
|
||||
$("#complete-build").on('click', function() {
|
||||
launchModalForm(
|
||||
"{% url 'build-complete' build.id %}",
|
||||
{
|
||||
reload: true,
|
||||
submit_text: "Complete Build",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
{% endblock %}
|
1
InvenTree/build/templates/build/complete.html
Normal file
1
InvenTree/build/templates/build/complete.html
Normal file
@ -0,0 +1 @@
|
||||
Mark as COMPLETE
|
@ -118,7 +118,7 @@
|
||||
launchModalForm("{% url 'build-cancel' build.id %}",
|
||||
{
|
||||
reload: true,
|
||||
submit_text: "Cancel",
|
||||
submit_text: "Cancel Build",
|
||||
});
|
||||
});
|
||||
{% endblock %}
|
||||
|
@ -20,6 +20,7 @@ build_detail_urls = [
|
||||
url(r'^edit/?', views.BuildUpdate.as_view(), name='build-edit'),
|
||||
url(r'^allocate/?', views.BuildAllocate.as_view(), name='build-allocate'),
|
||||
url(r'^cancel/?', views.BuildCancel.as_view(), name='build-cancel'),
|
||||
url(r'^complete/?', views.BuildComplete.as_view(), name='build-complete'),
|
||||
|
||||
url(r'^.*$', views.BuildDetail.as_view(), name='build-detail'),
|
||||
]
|
||||
|
@ -47,7 +47,7 @@ class BuildCancel(AjaxView):
|
||||
Provides a cancellation information dialog
|
||||
"""
|
||||
model = Build
|
||||
template_name = 'build/cancel.html'
|
||||
ajax_template_name = 'build/cancel.html'
|
||||
ajax_form_title = 'Cancel Build'
|
||||
context_object_name = 'build'
|
||||
fields = []
|
||||
@ -57,8 +57,7 @@ class BuildCancel(AjaxView):
|
||||
|
||||
build = get_object_or_404(Build, pk=self.kwargs['pk'])
|
||||
|
||||
build.status = Build.CANCELLED
|
||||
build.save()
|
||||
build.cancelBuild()
|
||||
|
||||
return self.renderJsonResponse(request, None)
|
||||
|
||||
@ -69,6 +68,36 @@ class BuildCancel(AjaxView):
|
||||
}
|
||||
|
||||
|
||||
class BuildComplete(AjaxView):
|
||||
""" View to mark a build as Complete.
|
||||
|
||||
- Notifies the user of which parts will be removed from stock.
|
||||
- Removes allocated items from stock
|
||||
- Deletes pending BuildItem objects
|
||||
"""
|
||||
|
||||
model = Build
|
||||
ajax_template_name = "build/complete.html"
|
||||
ajax_form_title = "Complete Build"
|
||||
context_object_name = "build"
|
||||
fields = []
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
""" Handle POST request. Mark the build as COMPLETE """
|
||||
|
||||
build = get_object_or_404(Build, pk=self.kwargs['pk'])
|
||||
|
||||
build.complete()
|
||||
|
||||
return self.renderJsonResponse(request, None)
|
||||
|
||||
def get_data(self):
|
||||
""" Provide feedback data back to the form """
|
||||
return {
|
||||
'info': 'Build marked as COMPLETE'
|
||||
}
|
||||
|
||||
|
||||
class BuildDetail(DetailView):
|
||||
""" Detail view of a single Build object. """
|
||||
model = Build
|
||||
|
Reference in New Issue
Block a user