Order from supplier 'parts list' page

This commit is contained in:
Oliver Walters 2019-06-12 00:10:39 +10:00
parent e4f5cc8ccd
commit 74327d3094
2 changed files with 18 additions and 18 deletions

View File

@ -12,6 +12,7 @@
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Options
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href='#' id='multi-part-order' title='Order parts'>Order Parts</a></li>
</ul>
</div>
</div>
@ -101,4 +102,20 @@
url: "{% url 'api-part-supplier-list' %}"
});
$("#multi-part-order").click(function() {
var selections = $("#part-table").bootstrapTable("getSelections");
var parts = [];
selections.forEach(function(item) {
parts.push(item.part);
});
launchModalForm("/order/purchase-order/order-parts/", {
data: {
parts: parts,
},
});
});
{% endblock %}

View File

@ -160,8 +160,6 @@ class OrderParts(AjaxView):
ctx = {}
print("Getting context data")
ctx['parts'] = self.get_parts()
return ctx
@ -180,9 +178,6 @@ class OrderParts(AjaxView):
stock_id_list = self.request.GET.getlist('stock[]')
print("Looking up parts from stock items:")
print(stock_id_list)
""" Get a list of all the parts associated with the stock items.
- Base part must be purchaseable.
- Return a set of corresponding Part IDs
@ -205,15 +200,10 @@ class OrderParts(AjaxView):
except Part.DoesNotExist:
pass
# User has passed a list of part ID values
elif 'parts[]' in self.request.GET:
part_id_list = self.request.GET.getlist('parts[]')
print("Provided list of part:")
print(part_id_list)
parts = Part.objects.filter(
purchaseable=True,
id__in=part_id_list)
@ -221,8 +211,6 @@ class OrderParts(AjaxView):
for part in parts:
part_ids.add(part.id)
print("Parts:", part_ids)
# Create the list of parts
for id in part_ids:
try:
@ -238,10 +226,6 @@ class OrderParts(AjaxView):
self.request = request
print("GET HERE")
print(request.GET)
self.get_parts()
return self.renderJsonResponse(request)
@ -249,7 +233,6 @@ class OrderParts(AjaxView):
def post(self, request, *args, **kwargs):
self.request = request
print("POST here")
data = {
'form_valid': False,