diff --git a/InvenTree/build/migrations/0025_auto_20201020_1248.py b/InvenTree/build/migrations/0025_auto_20201020_1248.py new file mode 100644 index 0000000000..ecc0b73ac9 --- /dev/null +++ b/InvenTree/build/migrations/0025_auto_20201020_1248.py @@ -0,0 +1,24 @@ +# Generated by Django 3.0.7 on 2020-10-20 12:48 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('build', '0024_auto_20201020_1144'), + ] + + operations = [ + migrations.AddField( + model_name='build', + name='completed', + field=models.PositiveIntegerField(default=0, help_text='Number of stock items which have been completed', verbose_name='Completed items'), + ), + migrations.AlterField( + model_name='build', + name='quantity', + field=models.PositiveIntegerField(default=1, help_text='Number of stock items to build', validators=[django.core.validators.MinValueValidator(1)], verbose_name='Build Quantity'), + ), + ] diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 3ee6aad426..a22aae196f 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -62,21 +62,6 @@ class Build(MPTTModel): def get_absolute_url(self): return reverse('build-detail', kwargs={'pk': self.id}) - - def clean(self): - """ - Validation for Build object. - """ - - super().clean() - - # Build quantity must be an integer - # Maybe in the future this will be adjusted? - - if not self.quantity == int(self.quantity): - raise ValidationError({ - 'quantity': _("Build quantity must be integer value for trackable parts") - }) reference = models.CharField( unique=True, @@ -149,7 +134,13 @@ class Build(MPTTModel): verbose_name=_('Build Quantity'), default=1, validators=[MinValueValidator(1)], - help_text=_('Number of parts to build') + help_text=_('Number of stock items to build') + ) + + completed = models.PositiveIntegerField( + verbose_name=_('Completed items'), + default=0, + help_text=_('Number of stock items which have been completed') ) status = models.PositiveIntegerField( diff --git a/InvenTree/build/serializers.py b/InvenTree/build/serializers.py index 53e75942f0..6367673ce9 100644 --- a/InvenTree/build/serializers.py +++ b/InvenTree/build/serializers.py @@ -38,6 +38,7 @@ class BuildSerializer(InvenTreeModelSerializer): 'url', 'title', 'creation_date', + 'completed', 'completion_date', 'part', 'part_detail', @@ -51,9 +52,10 @@ class BuildSerializer(InvenTreeModelSerializer): ] read_only_fields = [ - 'status', + 'completed', 'creation_date', 'completion_data', + 'status', 'status_text', ] diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index a366459908..3a94398e87 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -68,11 +68,6 @@ src="{% static 'img/blank_image.png' %}"

{% trans "Build Details" %}

- - - - - @@ -88,6 +83,11 @@ src="{% static 'img/blank_image.png' %}" + + + + + {% if build.parent %} @@ -102,20 +102,6 @@ src="{% static 'img/blank_image.png' %}" {% endif %} - - - - -
{% trans "Build Order Reference" %}{{ build }}
{% trans "Part" %}{% trans "Status" %} {% build_status_label build.status %}
{% trans "Progress" %} {{ build.completed }} / {{ build.quantity }}
{{ build.sales_order }}
{% trans "BOM Price" %} - {% if bom_price %} - {{ bom_price }} - {% if build.part.has_complete_bom_pricing == False %} -
{% trans "BOM pricing is incomplete" %} - {% endif %} - {% else %} - {% trans "No pricing information" %} - {% endif %} -
{% endblock %} diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 7d4c21aa5b..b51d12f772 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -10,90 +10,133 @@
- - - - - - - - - - - - - - - - - - - - + + + + + {% endif %} + + + + + +
{% trans "Title" %}{{ build.title }}
{% trans "Part" %}{{ build.part.full_name }}
{% trans "Quantity" %}{{ build.quantity }}
{% trans "Stock Source" %} - {% if build.take_from %} - {{ build.take_from }} - {% else %} - {% trans "Stock can be taken from any available location." %} +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if build.batch %} + + + + + {% endif %} - - - - - - + + + + {% endif %} - - - - - - - -{% if build.batch %} - - - - - -{% endif %} -{% if build.link %} - - - - - -{% endif %} - - - - - -{% if build.is_active %} - - - - + + + + {% endif %} - - -{% endif %} -{% if build.completion_date %} - - - - - -{% endif %} -
{% trans "Description" %}{{ build.title }}
{% trans "Part" %}{{ build.part.full_name }}
{% trans "Quantity" %}{{ build.quantity }}
{% trans "Stock Source" %} + {% if build.take_from %} + {{ build.take_from }} + {% else %} + {% trans "Stock can be taken from any available location." %} + {% endif %} +
{% trans "Destination" %} + {% if build.destination %} + + {{ build.destination }} + + {% else %} + {% trans "Destination location not specified" %} + {% endif %} +
{% trans "Status" %}{% build_status_label build.status %}
{% trans "Progress" %}{{ build.completed }} / {{ build.quantity }}
{% trans "Batch" %}{{ build.batch }}
{% trans "Destination" %} - {% if build.destination %} - - {{ build.destination }} - - {% else %} - {% trans "Destination location not specified" %} + {% if build.parent %} +
{% trans "Parent Build" %}{{ build.parent }}
{% trans "Status" %}{% build_status_label build.status %}
{% trans "Batch" %}{{ build.batch }}
{% trans "External Link" %}{{ build.link }}
{% trans "Created" %}{{ build.creation_date }}
{% trans "Enough Parts?" %} - {% if build.can_build %} - {% trans "Yes" %} - {% else %} - {% trans "No" %} + {% if build.sales_order %} +
{% trans "Sales Order" %}{{ build.sales_order }}
{% trans "Completed" %}{{ build.completion_date }}{% if build.completed_by %}{{ build.completed_by }}{% endif %}
+ {% if build.link %} +
{% trans "External Link" %}{{ build.link }}
{% trans "Created" %}{{ build.creation_date }}
+ +
+ + + + + + + + {% if build.is_active %} + + + + + + {% endif %} + {% if build.completion_date %} + + + + + + {% endif %} + +
{% trans "BOM Price" %} + {% if bom_price %} + {{ bom_price }} + {% if build.part.has_complete_bom_pricing == False %} +
{% trans "BOM pricing is incomplete" %} + {% endif %} + {% else %} + {% trans "No pricing information" %} + {% endif %} +
{% trans "Enough Parts?" %} + {% if build.can_build %} + {% trans "Yes" %} + {% else %} + {% trans "No" %} + {% endif %} +
{% trans "Completed" %}{{ build.completion_date }}{% if build.completed_by %}{{ build.completed_by }}{% endif %}
+
+ {% endblock %} diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 1535ded420..f9079e1936 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -130,7 +130,7 @@ class StockItem(MPTTModel): status: Status of this StockItem (ref: InvenTree.status_codes.StockStatus) notes: Extra notes field build: Link to a Build (if this stock item was created from a build) - is_building: Boolean field indicating if this stock item is currently being built + is_building: Boolean field indicating if this stock item is currently being built (or is "in production") purchase_order: Link to a PurchaseOrder (if this stock item was created from a PurchaseOrder) infinite: If True this StockItem can never be exhausted sales_order: Link to a SalesOrder object (if the StockItem has been assigned to a SalesOrder) diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index d7eb987aab..2538dbd398 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -15,6 +15,20 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% block pre_content %} {% include 'stock/loc_link.html' with location=item.location %} +{% if item.is_building %} +
+ {% trans "This stock item is in production and cannot be edited." %}
+ {% trans "Edit the stock item from the build view." %}
+ + {% if item.build %} + + {{ item.build }} + + {% endif %} + +
+{% endif %} + {% if item.hasRequiredTests and not item.passedAllRequiredTests %}
{% trans "This stock item has not passed all required tests" %} @@ -79,7 +93,6 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
-
@@ -99,7 +112,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
- {% if roles.stock.change %} + {% if roles.stock.change and not item.is_building %}
{% endif %} - {% if roles.stock.change %} + {% if roles.stock.change and not item.is_building %}