Rename some fields

- Oops didn't think that through, gotta go through and fix the data now...
This commit is contained in:
Oliver Walters 2019-06-02 19:46:30 +10:00
parent fd2e2a71f9
commit ba26acd487
14 changed files with 97 additions and 21 deletions

View File

@ -445,9 +445,9 @@ class IndexView(TemplateView):
# TODO - Is there a less expensive way to get these from the database
context['to_order'] = [part for part in Part.objects.filter(purchaseable=True) if part.need_to_restock()]
# Generate a list of buildable parts which have stock below their minimum values
# Generate a list of assembly parts which have stock below their minimum values
# TODO - Is there a less expensive way to get these from the database
context['to_build'] = [part for part in Part.objects.filter(buildable=True) if part.need_to_restock()]
context['to_build'] = [part for part in Part.objects.filter(assembly=True) if part.need_to_restock()]
return context

View File

@ -129,8 +129,8 @@ class PartList(generics.ListCreateAPIView):
filter_fields = [
'is_template',
'variant_of',
'buildable',
'consumable',
'assembly',
'component',
'trackable',
'purchaseable',
'salable',

View File

@ -57,5 +57,5 @@
fields:
name: 'Bob'
description: 'Can we build it?'
buildable: true
assembly: true

View File

@ -101,8 +101,8 @@ class EditPartForm(HelperForm):
'default_supplier',
'units',
'minimum_stock',
'buildable',
'consumable',
'assembly',
'component',
'trackable',
'purchaseable',
'salable',

View File

@ -0,0 +1,42 @@
# Generated by Django 2.2 on 2019-06-02 09:44
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('part', '0006_auto_20190526_1215'),
]
operations = [
migrations.RemoveField(
model_name='part',
name='buildable',
),
migrations.RemoveField(
model_name='part',
name='consumable',
),
migrations.AddField(
model_name='part',
name='assembly',
field=models.BooleanField(default=False, help_text='Can this part be built from other parts?', verbose_name='Assembly'),
),
migrations.AddField(
model_name='part',
name='component',
field=models.BooleanField(default=True, help_text='Can this part be used to build other parts?', verbose_name='Component'),
),
migrations.AlterField(
model_name='bomitem',
name='part',
field=models.ForeignKey(help_text='Select parent part', limit_choices_to={'active': True, 'assembly': True}, on_delete=django.db.models.deletion.CASCADE, related_name='bom_items', to='part.Part'),
),
migrations.AlterField(
model_name='bomitem',
name='sub_part',
field=models.ForeignKey(help_text='Select part to be used in BOM', limit_choices_to={'active': True, 'component': True}, on_delete=django.db.models.deletion.CASCADE, related_name='used_in', to='part.Part'),
),
]

View File

@ -201,8 +201,8 @@ class Part(models.Model):
minimum_stock: Minimum preferred quantity to keep in stock
units: Units of measure for this part (default='pcs')
salable: Can this part be sold to customers?
buildable: Can this part be build from other parts?
consumable: Can this part be used to make other parts?
assembly: Can this part be build from other parts?
component: Can this part be used to make other parts?
purchaseable: Can this part be purchased from suppliers?
trackable: Trackable parts can have unique serial numbers assigned, etc, etc
active: Is this part active? Parts are deactivated instead of being deleted
@ -343,9 +343,9 @@ class Part(models.Model):
units = models.CharField(max_length=20, default="pcs", blank=True, help_text='Stock keeping units for this part')
buildable = models.BooleanField(default=False, help_text='Can this part be built from other parts?')
assembly = models.BooleanField(default=False, verbose_name='Assembly', help_text='Can this part be built from other parts?')
consumable = models.BooleanField(default=True, help_text='Can this part be used to build other parts?')
component = models.BooleanField(default=True, verbose_name='Component', help_text='Can this part be used to build other parts?')
trackable = models.BooleanField(default=False, help_text='Does this part have tracking for unique items?')
@ -858,7 +858,7 @@ class BomItem(models.Model):
part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='bom_items',
help_text='Select parent part',
limit_choices_to={
'buildable': True,
'assembly': True,
'active': True,
})
@ -867,7 +867,7 @@ class BomItem(models.Model):
sub_part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='used_in',
help_text='Select part to be used in BOM',
limit_choices_to={
'consumable': True,
'component': True,
'active': True
})

View File

@ -94,8 +94,8 @@ class PartSerializer(serializers.ModelSerializer):
# 'available_stock',
'units',
'trackable',
'buildable',
'consumable',
'assembly',
'component',
'trackable',
'salable',
'active',

View File

@ -100,13 +100,13 @@
</div>
<div class='col-sm-6'>
<table class='table table-striped'>
{% if part.buildable %}
{% if part.assembly %}
<tr>
<td><b>Assembly</b></td>
<td><i>This part can be assembled from other parts</i></td>
</tr>
{% endif %}
{% if part.consumable %}
{% if part.component %}
<tr>
<td><b>Component</b></td>
<td><i>This part can be used in assemblies</i></td>

View File

@ -78,7 +78,7 @@
<td>In Stock</td>
<td>{{ part.total_stock }}</td>
</tr>
{% if part.buildable %}
{% if part.assembly %}
<tr>
<td>Can Build</td>
<td>{{ part.can_build }}</td>

View File

@ -15,13 +15,13 @@
<a href="{% url 'part-allocation' part.id %}">Allocated <span class="badge">{{ part.allocation_count }}</span></a>
</li>
{% endif %}
{% if part.buildable %}
{% if part.assembly %}
<li{% ifequal tab 'bom' %} class="active"{% endifequal %}>
<a href="{% url 'part-bom' part.id %}">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 %}>
<a href="{% url 'part-build' part.id %}">Build<span class='badge'>{{ part.active_builds|length }}</span></a></li>
{% endif %}
{% if part.consumable or part.used_in_count > 0 %}
{% if part.component or part.used_in_count > 0 %}
<li{% ifequal tab 'used' %} class="active"{% endifequal %}>
<a href="{% url 'part-used-in' part.id %}">Used In{% if part.used_in_count > 0 %}<span class="badge">{{ part.used_in_count }}</span>{% endif %}</a></li>
{% endif %}

View File

@ -149,7 +149,7 @@ class PartAPITest(APITestCase):
response = self.client.post(url, data, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# Now try to create a BomItem which points to a non-buildable part (should fail)
# Now try to create a BomItem which points to a non-assembly part (should fail)
data['part'] = 3
response = self.client.post(url, data, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

View File

@ -124,6 +124,10 @@ function imageHoverIcon(url) {
* On mouseover, display a full-size version of the image
*/
if (!url) {
url = '/static/img/blank_image.png';
}
var html = `
<a class='hover-icon'>
<img class='hover-img-thumb' src='` + url + `'>

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2 on 2019-06-02 09:44
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('stock', '0004_auto_20190525_2356'),
]
operations = [
migrations.AlterField(
model_name='stockitem',
name='status',
field=models.PositiveIntegerField(choices=[(10, 'OK'), (50, 'Attention needed'), (55, 'Damaged'), (60, 'Destroyed'), (70, 'Lost')], default=10, validators=[django.core.validators.MinValueValidator(0)]),
),
]

View File

@ -37,17 +37,28 @@ InvenTree | Search Results
function onSearchResults(table, output) {
$(table).on('load-success.bs.table', function() {
var panel = $(output).parent('.panel-group');
var n = $(table).bootstrapTable('getData').length;
var text = '';
if (n == 0) {
text = '<i>No results</i>'
$(panel).hide();
$(table).hide();
} else {
text = n + ' result';
if (n > 1) {
text += 's';
}
$(panel).show();
}
$(output).html(text);