mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Bug fix for build completion form
This commit is contained in:
parent
50dbebdf59
commit
72c43d0c2d
26
InvenTree/build/migrations/0015_auto_20200425_1350.py
Normal file
26
InvenTree/build/migrations/0015_auto_20200425_1350.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 3.0.5 on 2020-04-25 13:50
|
||||||
|
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import mptt.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('build', '0014_auto_20200425_1243'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='build',
|
||||||
|
name='parent',
|
||||||
|
field=mptt.fields.TreeForeignKey(blank=True, help_text='Parent build to which this build is allocated', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='children', to='build.Build', verbose_name='Parent Build'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='builditem',
|
||||||
|
name='quantity',
|
||||||
|
field=models.DecimalField(decimal_places=5, default=1, help_text='Stock quantity to allocate to build', max_digits=15, validators=[django.core.validators.MinValueValidator(0)]),
|
||||||
|
),
|
||||||
|
]
|
@ -329,8 +329,6 @@ class Build(MPTTModel):
|
|||||||
for item in bom_items:
|
for item in bom_items:
|
||||||
part = item.sub_part
|
part = item.sub_part
|
||||||
|
|
||||||
print("Checking:", part)
|
|
||||||
|
|
||||||
if not self.isPartFullyAllocated(part):
|
if not self.isPartFullyAllocated(part):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -353,8 +351,6 @@ class Build(MPTTModel):
|
|||||||
except BomItem.DoesNotExist:
|
except BomItem.DoesNotExist:
|
||||||
q = 0
|
q = 0
|
||||||
|
|
||||||
print("required quantity:", q, "*", self.quantity)
|
|
||||||
|
|
||||||
return q * self.quantity
|
return q * self.quantity
|
||||||
|
|
||||||
def getAllocatedQuantity(self, part):
|
def getAllocatedQuantity(self, part):
|
||||||
@ -499,6 +495,6 @@ class BuildItem(models.Model):
|
|||||||
decimal_places=5,
|
decimal_places=5,
|
||||||
max_digits=15,
|
max_digits=15,
|
||||||
default=1,
|
default=1,
|
||||||
validators=[MinValueValidator(1)],
|
validators=[MinValueValidator(0)],
|
||||||
help_text=_('Stock quantity to allocate to build')
|
help_text=_('Stock quantity to allocate to build')
|
||||||
)
|
)
|
||||||
|
@ -70,6 +70,17 @@ InvenTree | Allocate Parts
|
|||||||
build: {{ build.id }},
|
build: {{ build.id }},
|
||||||
quantity: getUnallocated(row),
|
quantity: getUnallocated(row),
|
||||||
},
|
},
|
||||||
|
secondary: [
|
||||||
|
{
|
||||||
|
field: 'stock_item',
|
||||||
|
label: '{% trans "New Stock Item" %}',
|
||||||
|
title: '{% trans "Create new Stock Item"',
|
||||||
|
url: '{% url "stock-item-create" %}',
|
||||||
|
data: {
|
||||||
|
part: row.sub_part,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -261,13 +261,13 @@ class BuildComplete(AjaxUpdateView):
|
|||||||
try:
|
try:
|
||||||
location = StockLocation.objects.get(id=loc_id)
|
location = StockLocation.objects.get(id=loc_id)
|
||||||
valid = True
|
valid = True
|
||||||
except StockLocation.DoesNotExist:
|
except (ValueError, StockLocation.DoesNotExist):
|
||||||
form.errors['location'] = [_('Invalid location selected')]
|
form.errors['location'] = [_('Invalid location selected')]
|
||||||
|
|
||||||
serials = []
|
serials = []
|
||||||
|
|
||||||
if build.part.trackable:
|
if build.part.trackable:
|
||||||
# A build for a trackable part must specify serial numbers
|
# A build for a trackable part may optionally specify serial numbers.
|
||||||
|
|
||||||
sn = request.POST.get('serial_numbers', '')
|
sn = request.POST.get('serial_numbers', '')
|
||||||
|
|
||||||
@ -295,7 +295,9 @@ class BuildComplete(AjaxUpdateView):
|
|||||||
valid = False
|
valid = False
|
||||||
|
|
||||||
if valid:
|
if valid:
|
||||||
build.completeBuild(location, serials, request.user)
|
if not build.completeBuild(location, serials, request.user):
|
||||||
|
form.non_field_errors = [('Build could not be completed')]
|
||||||
|
valid = False
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'form_valid': valid,
|
'form_valid': valid,
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<li{% ifequal tab 'bom' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'bom' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-bom' part.id %}">{% trans "BOM" %}<span class="badge{% if part.is_bom_valid == False %} badge-alert{% endif %}">{{ part.bom_count }}</span></a></li>
|
<a href="{% url 'part-bom' part.id %}">{% trans "BOM" %}<span class="badge{% if part.is_bom_valid == False %} badge-alert{% endif %}">{{ part.bom_count }}</span></a></li>
|
||||||
<li{% ifequal tab 'build' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'build' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-build' part.id %}">{% trans "Build" %}<span class='badge'>{{ part.active_builds|length }}</span></a></li>
|
<a href="{% url 'part-build' part.id %}">{% trans "Build Orders" %}<span class='badge'>{{ part.active_builds|length }}</span></a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if part.component or part.used_in_count > 0 %}
|
{% if part.component or part.used_in_count > 0 %}
|
||||||
<li{% ifequal tab 'used' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'used' %} class="active"{% endifequal %}>
|
||||||
|
Loading…
Reference in New Issue
Block a user