Improve build base rendering

- Consolidate style
- Fix rendering of part pricing
This commit is contained in:
Oliver Walters 2020-04-12 00:31:59 +10:00
parent a65c80dbf3
commit fd8273e3e2
3 changed files with 71 additions and 52 deletions

View File

@ -24,60 +24,70 @@ InvenTree | Build - {{ build }}
</div>
</div>
<div class='media-body'>
<h4>Build Details</h4>
<p>
<div class='btn-row'>
<div class='btn-group'>
<button type='button' class='btn btn-default btn-glyph' id='build-edit' title='Edit Build'>
<span class='glyphicon glyphicon-edit'/>
</button>
{% if build.is_active %}
<button type='button' class='btn btn-default btn-glyph' id='build-complete' title="Complete Build">
<span class='glyphicon glyphicon-send'/>
</button>
<button type='button' class='btn btn-default btn-glyph' id='build-cancel' title='Cancel Build'>
<span class='glyphicon glyphicon-remove'/>
</button>
{% endif %}
{% if build.status == BuildStatus.CANCELLED %}
<button type='button' class='btn btn-default btn-glyph' id='build-delete' title='Delete Build'>
<span class='glyphicon glyphicon-trash'/>
</button>
{% endif %}
</div>
<h4>{% trans "Build" %}</h4>
<div class='btn-row'>
<div class='btn-group'>
<button type='button' class='btn btn-default btn-glyph' id='build-edit' title='Edit Build'>
<span class='glyphicon glyphicon-edit'/>
</button>
{% if build.is_active %}
<button type='button' class='btn btn-default btn-glyph' id='build-complete' title="Complete Build">
<span class='glyphicon glyphicon-send'/>
</button>
<button type='button' class='btn btn-default btn-glyph' id='build-cancel' title='Cancel Build'>
<span class='glyphicon glyphicon-remove'/>
</button>
{% endif %}
{% if build.status == BuildStatus.CANCELLED %}
<button type='button' class='btn btn-default btn-glyph' id='build-delete' title='Delete Build'>
<span class='glyphicon glyphicon-trash'/>
</button>
{% endif %}
</div>
</p>
<table class='table table-striped table-condensed'>
<tr>
<td>{{ build.title }}</td>
<td>{% build_status build.status %}</td>
</tr>
<tr>
<td>Part</td>
<td><a href="{% url 'part-detail' build.part.id %}">{{ build.part.full_name }}</a></td>
</tr>
<tr>
<td>Quantity</td>
<td>{{ build.quantity }}</td>
</tr>
<tr>
<td>BOM Price</td>
<td>
{% if bom_price %}
{{ bom_price }}
{% if build.part.has_complete_bom_pricing == False %}
<br><span class='warning-msg'><i>BOM pricing is incomplete</i></span>
{% endif %}
{% else %}
<span class='warning-msg'><i>No pricing information</i></span>
{% endif %}
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class='col-sm-6'>
<h4>{% trans "Build Details" %}</h4>
<table class='table table-striped table-condensed'>
<tr>
<td></td>
<td>{% trans "Build Title" %}</td>
<td>{{ build.title }}</td>
</tr>
<tr>
<td><span class='fas fa-shapes'></span></td>
<td>Part</td>
<td><a href="{% url 'part-detail' build.part.id %}">{{ build.part.full_name }}</a></td>
</tr>
<tr>
<td></td>
<td>{% trans "Quantity" %}</td>
<td>{{ build.quantity }}</td>
</tr>
<tr>
<td><span class='fas fa-info'></span></td>
<td>{% trans "Status" %}</td>
<td>{% build_status build.status %}</td>
</tr>
<tr>
<td><span class='fas fa-dollar-sign'></span></td>
<td>{% trans "BOM Price" %}</td>
<td>
{% if bom_price %}
{{ bom_price }}
{% if build.part.has_complete_bom_pricing == False %}
<br><span class='warning-msg'><i>BOM pricing is incomplete</i></span>
{% endif %}
{% else %}
<span class='warning-msg'><i>No pricing information</i></span>
{% endif %}
</td>
</tr>
</table>
</div>
</div>
</div>
<hr>

View File

@ -781,6 +781,9 @@ class Part(models.Model):
if min_price == max_price:
return min_price
min_price = min_price.normalize()
max_price = max_price.normalize()
return "{a} - {b}".format(a=min_price, b=max_price)
def get_supplier_price_range(self, quantity=1):
@ -804,6 +807,9 @@ class Part(models.Model):
if min_price is None or max_price is None:
return None
min_price = min_price.normalize()
max_price = max_price.normalize()
return (min_price, max_price)
def get_bom_price_range(self, quantity=1):
@ -837,6 +843,9 @@ class Part(models.Model):
if min_price is None or max_price is None:
return None
min_price = min_price.normalize()
max_price = max_price.normalize()
return (min_price, max_price)
def get_price_range(self, quantity=1, buy=True, bom=True):

View File

@ -4,7 +4,7 @@
{% decimal part.total_stock %}
{% if part.total_stock == 0 %}
<span class='label label-danger'>{% trans "No Stock" %}</span>
<span class='label label-danger label-right'>{% trans "No Stock" %}</span>
{% elif part.total_stock < part.minimum_stock %}
<span class='label label-warning'>{% trans "Low Stock" %}</span>
<span class='label label-warning label-right'>{% trans "Low Stock" %}</span>
{% endif %}