mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Improve number rendering of build allocation page
This commit is contained in:
parent
564635c368
commit
5ae7ca71d7
@ -27,21 +27,24 @@ function loadAllocationTable(table, part_id, part, url, required, button) {
|
|||||||
field: 'stock_item_detail',
|
field: 'stock_item_detail',
|
||||||
title: 'Stock Item',
|
title: 'Stock Item',
|
||||||
formatter: function(value, row, index, field) {
|
formatter: function(value, row, index, field) {
|
||||||
return '' + value.quantity + ' x ' + value.part_name + ' @ ' + value.location_name;
|
return '' + parseFloat(value.quantity) + ' x ' + value.part_name + ' @ ' + value.location_name;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'stock_item_detail.quantity',
|
field: 'stock_item_detail.quantity',
|
||||||
title: 'Available',
|
title: 'Available',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return parseFloat(value);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'quantity',
|
field: 'quantity',
|
||||||
title: 'Allocated',
|
title: 'Allocated',
|
||||||
formatter: function(value, row, index, field) {
|
formatter: function(value, row, index, field) {
|
||||||
var html = value;
|
var html = parseFloat(value);
|
||||||
|
|
||||||
var bEdit = "<button class='btn btn-primary item-edit-button btn-sm' type='button' title='Edit stock allocation' url='/build/item/" + row.pk + "/edit/'><span class='glyphicon glyphicon-small glyphicon-edit'></span></button>";
|
var bEdit = "<button class='btn item-edit-button btn-sm' type='button' title='Edit stock allocation' url='/build/item/" + row.pk + "/edit/'><span class='glyphicon glyphicon-small glyphicon-edit'></span></button>";
|
||||||
var bDel = "<button class='btn btn-danger item-del-button btn-sm' type='button' title='Delete stock allocation' url='/build/item/" + row.pk + "/delete/'><span class='glyphicon glyphicon-small glyphicon-trash'></span></button>";
|
var bDel = "<button class='btn item-del-button btn-sm' type='button' title='Delete stock allocation' url='/build/item/" + row.pk + "/delete/'><span class='glyphicon glyphicon-small glyphicon-trash'></span></button>";
|
||||||
|
|
||||||
html += "<div class='btn-group' style='float: right;'>" + bEdit + bDel + "</div>";
|
html += "<div class='btn-group' style='float: right;'>" + bEdit + bDel + "</div>";
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ from markdownx.models import MarkdownxField
|
|||||||
|
|
||||||
from InvenTree.status_codes import BuildStatus
|
from InvenTree.status_codes import BuildStatus
|
||||||
from InvenTree.fields import InvenTreeURLField
|
from InvenTree.fields import InvenTreeURLField
|
||||||
|
from InvenTree.helpers import decimal2string
|
||||||
|
|
||||||
from stock.models import StockItem
|
from stock.models import StockItem
|
||||||
from part.models import Part, BomItem
|
from part.models import Part, BomItem
|
||||||
@ -42,7 +43,7 @@ class Build(models.Model):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Build {q} x {part}".format(q=self.quantity, part=str(self.part))
|
return "Build {q} x {part}".format(q=decimal2string(self.quantity), part=str(self.part))
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('build-detail', kwargs={'pk': self.id})
|
return reverse('build-detail', kwargs={'pk': self.id})
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
{% block collapse_heading %}
|
{% block collapse_heading %}
|
||||||
<div class='col-sm-2'>
|
<div class='col-sm-2'>
|
||||||
<b>{{ item.sub_part.total_stock }}</b>
|
<b>{% decimal item.sub_part.total_stock %}</b>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-sm-2'>
|
<div class='col-sm-2'>
|
||||||
<b>{% multiply build.quantity item.quantity %}</b>
|
<b>{% multiply build.quantity item.quantity %}</b>
|
||||||
|
@ -27,7 +27,7 @@ def inrange(n, *args, **kwargs):
|
|||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def multiply(x, y, *args, **kwargs):
|
def multiply(x, y, *args, **kwargs):
|
||||||
""" Multiply two numbers together """
|
""" Multiply two numbers together """
|
||||||
return x * y
|
return decimal2string(x * y)
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
@ -40,7 +40,7 @@ def add(x, y, *args, **kwargs):
|
|||||||
def part_allocation_count(build, part, *args, **kwargs):
|
def part_allocation_count(build, part, *args, **kwargs):
|
||||||
""" Return the total number of <part> allocated to <build> """
|
""" Return the total number of <part> allocated to <build> """
|
||||||
|
|
||||||
return build.getAllocatedQuantity(part)
|
return decimal2string(build.getAllocatedQuantity(part))
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user