mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #374 from SchrodingersGat/build-allocated-view
Switch between display and edit mode for build allocations
This commit is contained in:
commit
28a226d08d
@ -70,6 +70,10 @@ class BuildItemList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
query = BuildItem.objects.all()
|
query = BuildItem.objects.all()
|
||||||
|
|
||||||
|
query = query.select_related('stock_item')
|
||||||
|
query = query.prefetch_related('stock_item__part')
|
||||||
|
query = query.prefetch_related('stock_item__part__category')
|
||||||
|
|
||||||
if part_pk:
|
if part_pk:
|
||||||
query = query.filter(stock_item__part=part_pk)
|
query = query.filter(stock_item__part=part_pk)
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ class BuildItemSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
part = serializers.IntegerField(source='stock_item.part.pk', read_only=True)
|
part = serializers.IntegerField(source='stock_item.part.pk', read_only=True)
|
||||||
part_name = serializers.CharField(source='stock_item.part.full_name', read_only=True)
|
part_name = serializers.CharField(source='stock_item.part.full_name', read_only=True)
|
||||||
|
part_image = serializers.CharField(source='stock_item.part.image.url', read_only=True)
|
||||||
stock_item_detail = StockItemSerializerBrief(source='stock_item', read_only=True)
|
stock_item_detail = StockItemSerializerBrief(source='stock_item', read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -54,6 +55,7 @@ class BuildItemSerializer(InvenTreeModelSerializer):
|
|||||||
'build',
|
'build',
|
||||||
'part',
|
'part',
|
||||||
'part_name',
|
'part_name',
|
||||||
|
'part_image',
|
||||||
'stock_item',
|
'stock_item',
|
||||||
'stock_item_detail',
|
'stock_item_detail',
|
||||||
'quantity'
|
'quantity'
|
||||||
|
@ -10,39 +10,11 @@ InvenTree | Allocate Parts
|
|||||||
|
|
||||||
{% include "build/tabs.html" with tab='allocate' %}
|
{% include "build/tabs.html" with tab='allocate' %}
|
||||||
|
|
||||||
<h4>Allocate Parts for Build</h4>
|
{% if editing %}
|
||||||
|
{% include "build/allocate_edit.html" %}
|
||||||
<div class='row'>
|
{% else %}
|
||||||
<div class='col-sm-6'>
|
{% include "build/allocate_view.html" %}
|
||||||
</div>
|
{% endif %}
|
||||||
<div class='col-sm-6'>
|
|
||||||
<div class='btn-group' style='float: right;'>
|
|
||||||
<button class='btn btn-primary' type='button' title='Automatic allocation' id='auto-allocate-build'>Auto Allocate</button>
|
|
||||||
<button class='btn btn-warning' type='button' title='Unallocate build stock' id='unallocate-build'>Unallocate</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<div class='row'>
|
|
||||||
<div class='col-sm-6'>
|
|
||||||
<h4>Part</h4>
|
|
||||||
</div>
|
|
||||||
<div class='col-sm-2'>
|
|
||||||
<h4>Available</h4>
|
|
||||||
</div>
|
|
||||||
<div class='col-sm-2'>
|
|
||||||
<h4>Required</h4>
|
|
||||||
</div>
|
|
||||||
<div class='col-sm-2'>
|
|
||||||
<h4>Allocated</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% for bom_item in bom_items.all %}
|
|
||||||
{% include "build/allocation_item.html" with item=bom_item build=build collapse_id=bom_item.id %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@ -55,6 +27,8 @@ InvenTree | Allocate Parts
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
|
{% if editing %}
|
||||||
|
|
||||||
{% for bom_item in bom_items.all %}
|
{% for bom_item in bom_items.all %}
|
||||||
|
|
||||||
loadAllocationTable(
|
loadAllocationTable(
|
||||||
@ -86,4 +60,37 @@ InvenTree | Allocate Parts
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
$("#build-item-table").bootstrapTable({
|
||||||
|
url: "{% url 'api-build-item-list' %}",
|
||||||
|
queryParams: {
|
||||||
|
build: {{ build.id }},
|
||||||
|
},
|
||||||
|
search: true,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'part_name',
|
||||||
|
title: 'Part',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return imageHoverIcon(row.part_image) + value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'stock_item_detail.location_name',
|
||||||
|
title: 'Location',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'quantity',
|
||||||
|
title: 'Quantity Allocated',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#btn-allocate").click(function() {
|
||||||
|
location.href = "{% url 'build-allocate' build.id %}?edit=1";
|
||||||
|
});
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
32
InvenTree/build/templates/build/allocate_edit.html
Normal file
32
InvenTree/build/templates/build/allocate_edit.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<h4>Allocate Stock to Build</h4>
|
||||||
|
|
||||||
|
<div class='row'>
|
||||||
|
<div class='col-sm-6'>
|
||||||
|
</div>
|
||||||
|
<div class='col-sm-6'>
|
||||||
|
<div class='btn-group' style='float: right;'>
|
||||||
|
<button class='btn btn-primary' type='button' title='Automatic allocation' id='auto-allocate-build'>Auto Allocate</button>
|
||||||
|
<button class='btn btn-warning' type='button' title='Unallocate build stock' id='unallocate-build'>Unallocate</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class='row'>
|
||||||
|
<div class='col-sm-6'>
|
||||||
|
<h4>Part</h4>
|
||||||
|
</div>
|
||||||
|
<div class='col-sm-2'>
|
||||||
|
<h4>Available</h4>
|
||||||
|
</div>
|
||||||
|
<div class='col-sm-2'>
|
||||||
|
<h4>Required</h4>
|
||||||
|
</div>
|
||||||
|
<div class='col-sm-2'>
|
||||||
|
<h4>Allocated</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% for bom_item in bom_items.all %}
|
||||||
|
{% include "build/allocation_item.html" with item=bom_item build=build collapse_id=bom_item.id %}
|
||||||
|
{% endfor %}
|
10
InvenTree/build/templates/build/allocate_view.html
Normal file
10
InvenTree/build/templates/build/allocate_view.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<h4>Stock Allocated to Build</h4>
|
||||||
|
|
||||||
|
<div id='#build-item-toolbar'>
|
||||||
|
<div class='btn-group'>
|
||||||
|
<button class='btn btn-primary' type='button' id='btn-allocate' title='Allocate Stock'>Allocate</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class='table table-condensed table-striped' id='build-item-table' data-toolbar='#build-item-toolbar'>
|
||||||
|
</table>
|
@ -34,3 +34,11 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js_ready %}
|
||||||
|
|
||||||
|
{{ block.super }}
|
||||||
|
|
||||||
|
$("#build-list").bootstrapTable({});
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -294,6 +294,9 @@ class BuildAllocate(DetailView):
|
|||||||
context['part'] = part
|
context['part'] = part
|
||||||
context['bom_items'] = bom_items
|
context['bom_items'] = bom_items
|
||||||
|
|
||||||
|
if str2bool(self.request.GET.get('edit', None)):
|
||||||
|
context['editing'] = True
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<table clas='table table-striped table-condensed' id='part-table' data-toolbar='#button-toolbar'>
|
<table class='table table-striped table-condensed' id='part-table' data-toolbar='#button-toolbar'>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user