mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Tweaks
This commit is contained in:
parent
2b91f69c7d
commit
ac03dab8de
@ -740,14 +740,7 @@ class Build(MPTTModel):
|
||||
parts = []
|
||||
|
||||
for item in self.part.bom_items.all().prefetch_related('sub_part'):
|
||||
part = {
|
||||
'part': item.sub_part,
|
||||
'per_build': item.quantity,
|
||||
'quantity': item.quantity * self.quantity,
|
||||
'allocated': self.getAllocatedQuantity(item.sub_part)
|
||||
}
|
||||
|
||||
parts.append(part)
|
||||
parts.append(item.sub_part)
|
||||
|
||||
return parts
|
||||
|
||||
|
@ -24,9 +24,11 @@ InvenTree | Allocate Parts
|
||||
<button class='btn btn-primary' type='button' id='btn-create-output' title='{% trans "Create new build output" %}'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "Create New Output" %}
|
||||
</button>
|
||||
<!--
|
||||
<button class='btn btn-primary' type='button' id='btn-order-parts' title='{% trans "Order required parts" %}'>
|
||||
<span class='fas fa-shopping-cart'></span> {% trans "Order Parts" %}
|
||||
</button>
|
||||
-->
|
||||
<button class='btn btn-danger' type='button' id='btn-unallocate' title='{% trans "Unallocate stock" %}'>
|
||||
<span class='fas fa-minus-circle'></span> {% trans "Unallocate Stock" %}
|
||||
</button>
|
||||
@ -86,7 +88,7 @@ InvenTree | Allocate Parts
|
||||
launchModalForm(
|
||||
"{% url 'build-unallocate' build.id %}",
|
||||
{
|
||||
success: reloadTable,
|
||||
reload: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -286,38 +286,43 @@ class BuildOutputDelete(AjaxUpdateView):
|
||||
|
||||
return initials
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
def validate(self, build, form, **kwargs):
|
||||
|
||||
build = self.get_object()
|
||||
form = self.get_form()
|
||||
data = form.cleaned_data
|
||||
|
||||
confirm = request.POST.get('confirm', False)
|
||||
confirm = data.get('confirm', False)
|
||||
|
||||
output_id = request.POST.get('output_id', None)
|
||||
if not confirm:
|
||||
form.add_error('confirm', _('Confirm unallocation of build stock'))
|
||||
form.add_error(None, _('Check the confirmation box'))
|
||||
|
||||
output_id = data.get('output_id', None)
|
||||
output = None
|
||||
|
||||
try:
|
||||
output = StockItem.objects.get(pk=output_id)
|
||||
except (ValueError, StockItem.DoesNotExist):
|
||||
output = None
|
||||
pass
|
||||
|
||||
valid = False
|
||||
|
||||
if confirm:
|
||||
if output:
|
||||
if not output.build == build:
|
||||
form.add_error(None, _('Build output does not match build'))
|
||||
else:
|
||||
form.add_error(None, _('Build output must be specified'))
|
||||
|
||||
def save(self, build, form, **kwargs):
|
||||
|
||||
output_id = form.cleaned_data.get('output_id')
|
||||
|
||||
output = StockItem.objects.get(pk=output_id)
|
||||
|
||||
build.deleteBuildOutput(output)
|
||||
valid = True
|
||||
else:
|
||||
form.add_error(None, _('Build or output not specified'))
|
||||
else:
|
||||
form.add_error('confirm', _('Confirm unallocation of build stock'))
|
||||
form.add_error(None, _('Check the confirmation box'))
|
||||
|
||||
data = {
|
||||
'form_valid': valid,
|
||||
def get_data(self):
|
||||
return {
|
||||
'danger': _('Build output deleted'),
|
||||
}
|
||||
|
||||
return self.renderJsonResponse(request, form, data)
|
||||
|
||||
|
||||
class BuildUnallocate(AjaxUpdateView):
|
||||
""" View to un-allocate all parts from a build.
|
||||
|
@ -910,9 +910,10 @@ class OrderParts(AjaxView):
|
||||
try:
|
||||
build = Build.objects.get(id=build_id)
|
||||
|
||||
parts = build.part.required_parts()
|
||||
parts = build.required_parts
|
||||
|
||||
for part in parts:
|
||||
|
||||
# If ordering from a Build page, ignore parts that we have enough of
|
||||
if part.quantity_to_order <= 0:
|
||||
continue
|
||||
|
@ -658,14 +658,14 @@ function loadBuildTable(table, options) {
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '{% trans "Quantity" %}',
|
||||
title: '{% trans "Completed" %}',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
return makeProgressBar(
|
||||
row.completed,
|
||||
row.quantity,
|
||||
{
|
||||
style: 'max',
|
||||
//style: 'max',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user