mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Tweaks
This commit is contained in:
parent
23ac83d2a8
commit
6245d65ebc
@ -22,7 +22,7 @@ from markdownx.models import MarkdownxField
|
|||||||
from mptt.models import MPTTModel, TreeForeignKey
|
from mptt.models import MPTTModel, TreeForeignKey
|
||||||
|
|
||||||
from InvenTree.status_codes import BuildStatus
|
from InvenTree.status_codes import BuildStatus
|
||||||
from InvenTree.helpers import increment, getSetting
|
from InvenTree.helpers import increment, getSetting, normalize
|
||||||
from InvenTree.validators import validate_build_order_reference
|
from InvenTree.validators import validate_build_order_reference
|
||||||
|
|
||||||
import InvenTree.fields
|
import InvenTree.fields
|
||||||
@ -589,8 +589,8 @@ class BuildItem(models.Model):
|
|||||||
|
|
||||||
if self.quantity > self.stock_item.quantity:
|
if self.quantity > self.stock_item.quantity:
|
||||||
errors['quantity'] = [_("Allocated quantity ({n}) must not exceed available quantity ({q})".format(
|
errors['quantity'] = [_("Allocated quantity ({n}) must not exceed available quantity ({q})".format(
|
||||||
n=self.quantity,
|
n=normalize(self.quantity),
|
||||||
q=self.stock_item.quantity
|
q=normalize(self.stock_item.quantity)
|
||||||
))]
|
))]
|
||||||
|
|
||||||
if self.stock_item.quantity - self.stock_item.allocation_count() + self.quantity < self.quantity:
|
if self.stock_item.quantity - self.stock_item.allocation_count() + self.quantity < self.quantity:
|
||||||
|
10
InvenTree/build/templates/build/edit_build_item.html
Normal file
10
InvenTree/build/templates/build/edit_build_item.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{% extends "modal_form.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block pre_form_content %}
|
||||||
|
<div class='alert alert-block alert-info'>
|
||||||
|
<p>
|
||||||
|
{% trans "Alter the quantity of stock allocated to the build output" %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -700,7 +700,7 @@ class BuildItemEdit(AjaxUpdateView):
|
|||||||
""" View to edit a BuildItem object """
|
""" View to edit a BuildItem object """
|
||||||
|
|
||||||
model = BuildItem
|
model = BuildItem
|
||||||
ajax_template_name = 'modal_form.html'
|
ajax_template_name = 'build/edit_build_item.html'
|
||||||
form_class = forms.EditBuildItemForm
|
form_class = forms.EditBuildItemForm
|
||||||
ajax_form_title = _('Edit Stock Allocation')
|
ajax_form_title = _('Edit Stock Allocation')
|
||||||
role_required = 'build.change'
|
role_required = 'build.change'
|
||||||
@ -720,14 +720,9 @@ class BuildItemEdit(AjaxUpdateView):
|
|||||||
|
|
||||||
form = super(BuildItemEdit, self).get_form()
|
form = super(BuildItemEdit, self).get_form()
|
||||||
|
|
||||||
query = StockItem.objects.all()
|
# Hide fields which we do not wish the user to edit
|
||||||
|
for field in ['build', 'stock_item', 'install_into']:
|
||||||
if build_item.stock_item:
|
if form[field].value():
|
||||||
part_id = build_item.stock_item.part.id
|
form.fields[field].widget = HiddenInput()
|
||||||
query = query.filter(part=part_id)
|
|
||||||
|
|
||||||
form.fields['stock_item'].queryset = query
|
|
||||||
|
|
||||||
form.fields['build'].widget = HiddenInput()
|
|
||||||
|
|
||||||
return form
|
return form
|
||||||
|
@ -252,7 +252,7 @@ function loadBuildOutputAllocationTable(buildId, partId, output, options={}) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'sub_part_detail.full_name',
|
field: 'sub_part_detail.full_name',
|
||||||
title: "{% trans "Required Part" %}",
|
title: '{% trans "Required Part" %}',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
formatter: function(value, row, index, field) {
|
formatter: function(value, row, index, field) {
|
||||||
var url = `/part/${row.sub_part}/`;
|
var url = `/part/${row.sub_part}/`;
|
||||||
@ -326,7 +326,7 @@ function loadBuildTable(table, options) {
|
|||||||
$(table).inventreeTable({
|
$(table).inventreeTable({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
formatNoMatches: function() {
|
formatNoMatches: function() {
|
||||||
return "{% trans "No builds matching query" %}";
|
return '{% trans "No builds matching query" %}';
|
||||||
},
|
},
|
||||||
url: options.url,
|
url: options.url,
|
||||||
queryParams: filters,
|
queryParams: filters,
|
||||||
|
Loading…
Reference in New Issue
Block a user