mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Improve number rendering of build allocation page
This commit is contained in:
		| @@ -27,21 +27,24 @@ function loadAllocationTable(table, part_id, part, url, required, button) { | ||||
|                 field: 'stock_item_detail', | ||||
|                 title: 'Stock Item', | ||||
|                 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', | ||||
|                 title: 'Available', | ||||
|                 formatter: function(value, row, index, field) { | ||||
|                     return parseFloat(value); | ||||
|                 } | ||||
|             }, | ||||
|             { | ||||
|                 field: 'quantity', | ||||
|                 title: 'Allocated', | ||||
|                 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 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 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 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>"; | ||||
|                      | ||||
|   | ||||
| @@ -20,6 +20,7 @@ from markdownx.models import MarkdownxField | ||||
|  | ||||
| from InvenTree.status_codes import BuildStatus | ||||
| from InvenTree.fields import InvenTreeURLField | ||||
| from InvenTree.helpers import decimal2string | ||||
|  | ||||
| from stock.models import StockItem | ||||
| from part.models import Part, BomItem | ||||
| @@ -42,7 +43,7 @@ class Build(models.Model): | ||||
|     """ | ||||
|  | ||||
|     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): | ||||
|         return reverse('build-detail', kwargs={'pk': self.id}) | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
|  | ||||
| {% block collapse_heading %} | ||||
|     <div class='col-sm-2'> | ||||
|         <b>{{ item.sub_part.total_stock }}</b> | ||||
|         <b>{% decimal item.sub_part.total_stock %}</b> | ||||
|     </div> | ||||
|     <div class='col-sm-2'> | ||||
|         <b>{% multiply build.quantity item.quantity %}</b> | ||||
|   | ||||
| @@ -27,7 +27,7 @@ def inrange(n, *args, **kwargs): | ||||
| @register.simple_tag() | ||||
| def multiply(x, y, *args, **kwargs): | ||||
|     """ Multiply two numbers together """ | ||||
|     return x * y | ||||
|     return decimal2string(x * y) | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
| @@ -40,7 +40,7 @@ def add(x, y, *args, **kwargs): | ||||
| def part_allocation_count(build, part, *args, **kwargs): | ||||
|     """ Return the total number of <part> allocated to <build> """ | ||||
|  | ||||
|     return build.getAllocatedQuantity(part) | ||||
|     return decimal2string(build.getAllocatedQuantity(part)) | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user