mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Ability to receive PO lines items individually
This commit is contained in:
parent
0d68dbcfa7
commit
8d92960f10
@ -108,9 +108,7 @@ InvenTree | {{ order }}
|
||||
<th data-sortable='true'>Received</th>
|
||||
{% endif %}
|
||||
<th>Note</th>
|
||||
{% if order.status == OrderStatus.PENDING %}
|
||||
<th></th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -137,18 +135,23 @@ InvenTree | {{ order }}
|
||||
<td>
|
||||
{{ line.notes }}
|
||||
</td>
|
||||
{% if order.status == OrderStatus.PENDING %}
|
||||
<td>
|
||||
<div class='btn-group'>
|
||||
{% if order.status == OrderStatus.PENDING %}
|
||||
<button class='btn btn-default btn-glyph' line='{{ line.id }}' id='edit-line-item-{{ line.id }} title='Edit line item' onclick='editPurchaseOrderLineItem()'>
|
||||
<span url="{% url 'po-line-item-edit' line.id %}" line='{{ line.id }}' class='glyphicon glyphicon-edit'></span>
|
||||
</button>
|
||||
<button class='btn btn-default btn-glyph' line='{{ line.id }}' id='remove-line-item-{{ line.id }' title='Remove line item' type='button' onclick='removePurchaseOrderLineItem()'>
|
||||
<span url="{% url 'po-line-item-delete' line.id %}" line='{{ line.id }}' class='glyphicon glyphicon-remove'></span>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if order.status == OrderStatus.PLACED and line.received < line.quantity %}
|
||||
<button class='btn btn-default btn-glyph line-receive' pk='{{ line.pk }}' title='Receive item(s)'>
|
||||
<span class='glyphicon glyphicon-check'></span>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@ -187,6 +190,20 @@ $("#cancel-order").click(function() {
|
||||
});
|
||||
});
|
||||
|
||||
$("#po-lines-table").on('click', ".line-receive", function() {
|
||||
|
||||
var button = $(this);
|
||||
|
||||
console.log('clicked! ' + button.attr('pk'));
|
||||
|
||||
launchModalForm("{% url 'purchase-order-receive' order.id %}", {
|
||||
reload: true,
|
||||
data: {
|
||||
line: button.attr('pk')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#receive-order").click(function() {
|
||||
launchModalForm("{% url 'purchase-order-receive' order.id %}", {
|
||||
reload: true,
|
||||
|
@ -230,6 +230,31 @@ class PurchaseOrderReceive(AjaxUpdateView):
|
||||
|
||||
return ctx
|
||||
|
||||
def get_lines(self):
|
||||
"""
|
||||
Extract particular line items from the request,
|
||||
or default to *all* pending line items if none are provided
|
||||
"""
|
||||
|
||||
lines = None
|
||||
|
||||
if 'line' in self.request.GET:
|
||||
line_id = self.request.GET.get('line')
|
||||
|
||||
try:
|
||||
lines = PurchaseOrderLineItem.objects.filter(pk=line_id)
|
||||
except (PurchaseOrderLineItem.DoesNotExist, ValueError):
|
||||
pass
|
||||
|
||||
# TODO - Option to pass multiple lines?
|
||||
|
||||
# No lines specified - default selection
|
||||
if lines is None:
|
||||
lines = self.order.pending_line_items()
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
""" Respond to a GET request. Determines which parts are outstanding,
|
||||
and presents a list of these parts to the user.
|
||||
@ -238,7 +263,7 @@ class PurchaseOrderReceive(AjaxUpdateView):
|
||||
self.request = request
|
||||
self.order = get_object_or_404(PurchaseOrder, pk=self.kwargs['pk'])
|
||||
|
||||
self.lines = self.order.pending_line_items()
|
||||
self.lines = self.get_lines()
|
||||
|
||||
for line in self.lines:
|
||||
# Pre-fill the remaining quantity
|
||||
|
Loading…
Reference in New Issue
Block a user