mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #671 from SchrodingersGat/allocation-add
Bugfix: Build Allocation
This commit is contained in:
commit
3b6ed585ab
@ -71,7 +71,7 @@ function loadAllocationTable(table, part_id, part, url, required, button) {
|
||||
var count = 0;
|
||||
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
count += results[i].quantity;
|
||||
count += parseFloat(results[i].quantity);
|
||||
}
|
||||
|
||||
updateAllocationTotal(part_id, count, required);
|
||||
|
@ -18,7 +18,7 @@
|
||||
<b>{% decimal item.sub_part.total_stock %}</b>
|
||||
</div>
|
||||
<div class='col-sm-2'>
|
||||
<b>{% multiply build.quantity item.quantity %}</b>
|
||||
<b>{% multiply build.quantity item.quantity %}{% if item.overage %} (+ {{ item.overage }}){% endif %}</b>
|
||||
</div>
|
||||
<div class='col-sm-2'>
|
||||
<b><span id='allocation-total-{{ item.sub_part.id }}'>{% part_allocation_count build item.sub_part %}</span></b>
|
||||
|
@ -21,19 +21,49 @@ InvenTree | {% trans "Supplier Part" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='col-sm-6'>
|
||||
<div class='media-left'>
|
||||
<img class='part-thumb'
|
||||
{% if part.part.image %}
|
||||
src='{{ part.part.image.url }}'
|
||||
{% else %}
|
||||
src="{% static 'img/blank_image.png' %}"
|
||||
{% endif %}/>
|
||||
<img class='part-thumb'
|
||||
{% if part.part.image %}
|
||||
src='{{ part.part.image.url }}'
|
||||
{% else %}
|
||||
src="{% static 'img/blank_image.png' %}"
|
||||
{% endif %}/>
|
||||
</div>
|
||||
</div>
|
||||
<div class='col-sm-6'>
|
||||
<h4>{% trans "Supplier Part Details" %}</h4>
|
||||
<table class="table table-striped table-condensed">
|
||||
<tr>
|
||||
<td>{% trans "Internal Part" %}</td>
|
||||
<td>
|
||||
{% if part.part %}
|
||||
<a href="{% url 'part-suppliers' part.part.id %}">{{ part.part.full_name }}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>{% trans "Supplier" %}</td><td><a href="{% url 'company-detail-parts' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<tr><td>{% trans "SKU" %}</td><td>{{ part.SKU }}</tr></tr>
|
||||
{% if part.URL %}
|
||||
<tr><td>{% trans "URL" %}</td><td><a href="{{ part.URL }}">{{ part.URL }}</a></td></tr>
|
||||
{% endif %}
|
||||
{% if part.description %}
|
||||
<tr><td>{% trans "Description" %}</td><td>{{ part.description }}</td></tr>
|
||||
{% endif %}
|
||||
{% if part.manufacturer %}
|
||||
<tr><td>{% trans "Manufacturer" %}</td><td>{{ part.manufacturer }}</td></tr>
|
||||
<tr><td>{% trans "MPN" %}</td><td>{{ part.MPN }}</td></tr>
|
||||
{% endif %}
|
||||
{% if part.note %}
|
||||
<tr><td>{% trans "Note" %}</td><td>{{ part.note }}</td></tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<div class='container-fluid'>
|
||||
|
@ -1,9 +1,6 @@
|
||||
{% load i18n %}
|
||||
|
||||
<ul class='nav nav-tabs'>
|
||||
<li{% if tab == 'details' %} class='active'{% endif %}>
|
||||
<a href="{% url 'supplier-part-detail' part.id %}">{% trans "Details" %}</a>
|
||||
</li>
|
||||
<li{% if tab == 'pricing' %} class='active'{% endif %}>
|
||||
<a href="{% url 'supplier-part-pricing' part.id %}">{% trans "Pricing" %}</a>
|
||||
</li>
|
||||
|
@ -53,7 +53,7 @@ supplier_part_detail_urls = [
|
||||
url(r'^orders/', views.SupplierPartDetail.as_view(template_name='company/supplier_part_orders.html'), name='supplier-part-orders'),
|
||||
url(r'^stock/', views.SupplierPartDetail.as_view(template_name='company/supplier_part_stock.html'), name='supplier-part-stock'),
|
||||
|
||||
url('^.*$', views.SupplierPartDetail.as_view(), name='supplier-part-detail'),
|
||||
url('^.*$', views.SupplierPartDetail.as_view(template_name='company/supplier_part_pricing.html'), name='supplier-part-detail'),
|
||||
]
|
||||
|
||||
supplier_part_urls = [
|
||||
|
@ -1198,9 +1198,9 @@ class BomItem(models.Model):
|
||||
|
||||
overage = str(self.overage).strip()
|
||||
|
||||
# Is the overage an integer value?
|
||||
# Is the overage a numerical value?
|
||||
try:
|
||||
ovg = int(overage)
|
||||
ovg = float(overage)
|
||||
|
||||
if ovg < 0:
|
||||
ovg = 0
|
||||
@ -1223,7 +1223,7 @@ class BomItem(models.Model):
|
||||
# Must be represented as a decimal
|
||||
percent = Decimal(percent)
|
||||
|
||||
return int(percent * quantity)
|
||||
return float(percent * quantity)
|
||||
|
||||
except ValueError:
|
||||
pass
|
||||
@ -1245,7 +1245,12 @@ class BomItem(models.Model):
|
||||
# Base quantity requirement
|
||||
base_quantity = self.quantity * build_quantity
|
||||
|
||||
return base_quantity + self.get_overage_quantity(base_quantity)
|
||||
# Overage requiremet
|
||||
ovrg_quantity = self.get_overage_quantity(base_quantity)
|
||||
|
||||
required = float(base_quantity) + float(ovrg_quantity)
|
||||
|
||||
return required
|
||||
|
||||
@property
|
||||
def price_range(self):
|
||||
|
@ -38,7 +38,7 @@ from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDelete
|
||||
from InvenTree.views import QRCodeView
|
||||
|
||||
from InvenTree.helpers import DownloadFile, str2bool
|
||||
from InvenTree.status_codes import OrderStatus
|
||||
from InvenTree.status_codes import OrderStatus, BuildStatus
|
||||
|
||||
|
||||
class PartIndex(ListView):
|
||||
@ -593,6 +593,7 @@ class PartDetail(DetailView):
|
||||
context['disabled'] = not part.active
|
||||
|
||||
context['OrderStatus'] = OrderStatus
|
||||
context['BuildStatus'] = BuildStatus
|
||||
|
||||
return context
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user