2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 20:45:44 +00:00

Make build allocation much more intuiitive

- Display current allocation + total allocation requirement
- Color code results
- Required custom 'multiply' template tag
This commit is contained in:
Oliver Walters
2019-05-01 22:12:09 +10:00
parent ad1d75c259
commit 98109bb1a1
6 changed files with 74 additions and 3 deletions

View File

@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load static %}
{% load inventree_extras %}
{% block content %}
@ -36,8 +37,10 @@
loadAllocationTable(
$("#allocate-table-id-{{ bom_item.sub_part.id }}"),
{{ bom_item.sub_part.id }},
"{{ bom_item.sub_part.name }}",
"{% url 'api-build-item-list' %}?build={{ build.id }}&part={{ bom_item.sub_part.id }}",
{% multiply build.quantity bom_item.quantity %},
$("#new-item-{{ bom_item.sub_part.id }}")
);

View File

@ -1,3 +1,5 @@
{% load inventree_extras %}
<div class='panel-group'>
<div class='panel pane-default'>
<div class='panel panel-heading'>
@ -7,7 +9,19 @@
<a data-toggle='collapse' href='#collapse-item-{{ item.id }}'>{{ item.sub_part.name }}</a>
</div>
</div>
<div class='col-sm-6'>
<div class='col-sm-1' align='right'>
Required:
</div>
<div class='col-sm-1'>
<b>{% multiply build.quantity item.quantity %}</b>
</div>
<div class='col-sm-1' align='right'>
Allocated:
</div>
<div class='col-sm-1' id='allocation-panel-{{ item.sub_part.id }}'>
<b><span id='allocation-total-{{ item.sub_part.id }}'>0</span></b>
</div>
<div class='col-sm-2'>
<div class='btn-group' style='float: right;'>
<button class='btn btn-success btn-sm' id='new-item-{{ item.sub_part.id }}' url="{% url 'build-item-create' %}?part={{ item.sub_part.id }}&build={{ build.id }}">Allocate Parts</button>
</div>

View File

View File

@ -0,0 +1,12 @@
""" This module provides template tags for extra functionality
over and above the built-in Django tags.
"""
from django import template
register = template.Library()
@register.simple_tag()
def multiply(x, y, *args, **kwargs):
return x * y