From 61351a8f8d34fd26a2b7859053442b332726395c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 9 May 2019 22:52:38 +1000 Subject: [PATCH 01/10] Renamed add_transaction_note to addTransactionNote --- InvenTree/stock/models.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 537397f66b..4a2e8bc358 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -81,7 +81,7 @@ class StockItem(models.Model): if add_note: # This StockItem is being saved for the first time - self.add_transaction_note( + self.addTransactionNote( 'Created stock item', None, notes="Created new stock item for part '{p}'".format(p=str(self.part)), @@ -209,6 +209,8 @@ class StockItem(models.Model): review_needed = models.BooleanField(default=False) + delete_on_deplete = models.BooleanField(default=True, help_text='Delete this Stock Item when stock is depleted') + ITEM_OK = 10 ITEM_ATTENTION = 50 ITEM_DAMAGED = 55 @@ -249,7 +251,11 @@ class StockItem(models.Model): def has_tracking_info(self): return self.tracking_info.count() > 0 - def add_transaction_note(self, title, user, notes='', system=True): + def addTransactionNote(self, title, user, notes='', system=True): + """ Generation a stock transaction note for this item. + + Brief automated note detailing a movement or quantity change. + """ track = StockItemTracking.objects.create( item=self, title=title, @@ -280,7 +286,7 @@ class StockItem(models.Model): self.location = location self.save() - self.add_transaction_note(msg, + self.addTransactionNote(msg, user, notes=notes, system=True) @@ -304,7 +310,7 @@ class StockItem(models.Model): self.stocktake_user = user self.save() - self.add_transaction_note('Stocktake - counted {n} items'.format(n=count), + self.addTransactionNote('Stocktake - counted {n} items'.format(n=count), user, notes=notes, system=True) @@ -328,7 +334,7 @@ class StockItem(models.Model): self.save() - self.add_transaction_note('Added {n} items to stock'.format(n=quantity), + self.addTransactionNote('Added {n} items to stock'.format(n=quantity), user, notes=notes, system=True) @@ -355,7 +361,7 @@ class StockItem(models.Model): self.save() - self.add_transaction_note('Removed {n} items from stock'.format(n=quantity), + self.addTransactionNote('Removed {n} items from stock'.format(n=quantity), user, notes=notes, system=True) From ac326c135fe3912c17ed4c5bfb6f1495ef1e4dfe Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 9 May 2019 23:01:32 +1000 Subject: [PATCH 02/10] Auto delete stock items when they are depleted --- .../0015_stockitem_delete_on_deplete.py | 18 +++++ InvenTree/stock/models.py | 67 ++++++++++++------- 2 files changed, 60 insertions(+), 25 deletions(-) create mode 100644 InvenTree/stock/migrations/0015_stockitem_delete_on_deplete.py diff --git a/InvenTree/stock/migrations/0015_stockitem_delete_on_deplete.py b/InvenTree/stock/migrations/0015_stockitem_delete_on_deplete.py new file mode 100644 index 0000000000..29631b94d8 --- /dev/null +++ b/InvenTree/stock/migrations/0015_stockitem_delete_on_deplete.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2 on 2019-05-09 12:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0014_auto_20190508_2332'), + ] + + operations = [ + migrations.AddField( + model_name='stockitem', + name='delete_on_deplete', + field=models.BooleanField(default=True, help_text='Delete this Stock Item when stock is depleted'), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 4a2e8bc358..a5f323268a 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -284,15 +284,39 @@ class StockItem(models.Model): msg += " (from {loc})".format(loc=str(self.location)) self.location = location - self.save() self.addTransactionNote(msg, user, notes=notes, system=True) + self.save() + return True + @transaction.atomic + def updateQuantity(self, quantity): + """ Update stock quantity for this item. + + If the quantity has reached zero, this StockItem will be deleted. + + Returns: + - True if the quantity was saved + - False if the StockItem was deleted + """ + + if quantity < 0: + quantity = 0 + + self.quantity = quantity + + if quantity <= 0 and self.delete_on_deplete: + self.delete() + return False + else: + self.save() + return True + @transaction.atomic def stocktake(self, count, user, notes=''): """ Perform item stocktake. @@ -305,15 +329,15 @@ class StockItem(models.Model): if count < 0 or self.infinite: return False - self.quantity = count self.stocktake_date = datetime.now().date() self.stocktake_user = user - self.save() - self.addTransactionNote('Stocktake - counted {n} items'.format(n=count), - user, - notes=notes, - system=True) + if self.updateQuantity(count): + + self.addTransactionNote('Stocktake - counted {n} items'.format(n=count), + user, + notes=notes, + system=True) return True @@ -330,14 +354,12 @@ class StockItem(models.Model): if quantity <= 0 or self.infinite: return False - self.quantity += quantity - - self.save() - - self.addTransactionNote('Added {n} items to stock'.format(n=quantity), - user, - notes=notes, - system=True) + if self.updateQuantity(self.quantity + quantity): + + self.addTransactionNote('Added {n} items to stock'.format(n=quantity), + user, + notes=notes, + system=True) return True @@ -354,17 +376,12 @@ class StockItem(models.Model): if quantity <= 0 or self.infinite: return False - self.quantity -= quantity + if self.updateQuantity(self.quantity - quantity): - if self.quantity < 0: - self.quantity = 0 - - self.save() - - self.addTransactionNote('Removed {n} items from stock'.format(n=quantity), - user, - notes=notes, - system=True) + self.addTransactionNote('Removed {n} items from stock'.format(n=quantity), + user, + notes=notes, + system=True) return True From 027e1cf130e41afafe4a6e011ea40d0c1bbbb1e4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 9 May 2019 23:06:19 +1000 Subject: [PATCH 03/10] Add ability to edit 'delete_on_deplete' field --- InvenTree/stock/forms.py | 2 ++ InvenTree/stock/models.py | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py index c040c58fce..f181a6db88 100644 --- a/InvenTree/stock/forms.py +++ b/InvenTree/stock/forms.py @@ -34,6 +34,7 @@ class CreateStockItemForm(HelperForm): 'location', 'batch', 'quantity', + 'delete_on_deplete', 'status', 'notes', 'URL', @@ -78,6 +79,7 @@ class EditStockItemForm(HelperForm): fields = [ 'supplier_part', 'batch', + 'delete_on_deplete', 'status', 'notes', 'URL', diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index a5f323268a..2caa3940cd 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -286,9 +286,9 @@ class StockItem(models.Model): self.location = location self.addTransactionNote(msg, - user, - notes=notes, - system=True) + user, + notes=notes, + system=True) self.save() @@ -296,8 +296,8 @@ class StockItem(models.Model): @transaction.atomic def updateQuantity(self, quantity): - """ Update stock quantity for this item. - + """ Update stock quantity for this item. + If the quantity has reached zero, this StockItem will be deleted. Returns: From 7835562396fc155f327a05505bfa515482c5fe7a Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 9 May 2019 23:55:30 +1000 Subject: [PATCH 04/10] Auto-allocation form now working - Displays a list of stock items which will be allocated --- InvenTree/build/forms.py | 12 ++++ InvenTree/build/models.py | 24 ++++++-- InvenTree/build/templates/build/allocate.html | 12 +++- .../build/templates/build/auto_allocate.html | 43 ++++++++++++++ InvenTree/build/templates/build/complete.html | 2 +- InvenTree/build/urls.py | 1 + InvenTree/build/views.py | 57 ++++++++++++++++++- 7 files changed, 142 insertions(+), 9 deletions(-) create mode 100644 InvenTree/build/templates/build/auto_allocate.html diff --git a/InvenTree/build/forms.py b/InvenTree/build/forms.py index de56ca34f7..d46138cd09 100644 --- a/InvenTree/build/forms.py +++ b/InvenTree/build/forms.py @@ -27,6 +27,18 @@ class EditBuildForm(HelperForm): ] +class AutoAllocateBuildForm(HelperForm): + """ Form for auto-allocation of stock to a build """ + + confirm = forms.BooleanField(required=False, help_text='Confirm stock allocation') + + class Meta: + model = Build + fields = [ + 'confirm' + ] + + class CompleteBuildForm(HelperForm): """ Form for marking a Build as complete """ diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index fedcb76403..2c9077f3d7 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -127,10 +127,10 @@ class Build(models.Model): - If there are multiple StockItems available, ignore (leave up to the user) Returns: - A dict object containing the StockItem objects to be allocated (and the quantities) + A list object containing the StockItem objects to be allocated (and the quantities) """ - allocations = {} + allocations = [] for item in self.part.bom_items.all(): @@ -151,12 +151,17 @@ class Build(models.Model): # Are there any parts available? if stock_item.quantity > 0: + # Only take as many as are available if stock_item.quantity < q_required: q_required = stock_item.quantity - # Add the item to the allocations list - allocations[stock_item] = q_required + allocation = { + 'stock_item': stock_item, + 'quantity': q_required, + } + + allocations.append(allocation) return allocations @@ -164,6 +169,13 @@ class Build(models.Model): def autoAllocate(self): """ Run auto-allocation routine to allocate StockItems to this Build. + Returns a list of dict objects with keys like: + + { + 'stock_item': item, + 'quantity': quantity, + } + See: getAutoAllocations() """ @@ -173,8 +185,8 @@ class Build(models.Model): # Create a new allocation build_item = BuildItem( build=self, - stock_item=item, - quantity=allocations[item]) + stock_item=item['stock_item'], + quantity=item['quantity']) build_item.save() diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index 1aa5338551..b3d7dd1009 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -18,7 +18,8 @@ InvenTree | Allocate Parts
- + +
@@ -64,4 +65,13 @@ InvenTree | Allocate Parts ); }); + $("#auto-allocate-build").on('click', function() { + launchModalForm( + "{% url 'build-auto-allocate' build.id %}", + { + reload: true, + } + ); + }); + {% endblock %} diff --git a/InvenTree/build/templates/build/auto_allocate.html b/InvenTree/build/templates/build/auto_allocate.html new file mode 100644 index 0000000000..ba789b9ff7 --- /dev/null +++ b/InvenTree/build/templates/build/auto_allocate.html @@ -0,0 +1,43 @@ +{% extends "modal_form.html" %} + +{% block pre_form_content %} + +{{ block.super }} + +Build: {{ build.title }} - {{ build.quantity }} x {{ build.part.name }} +

+Automatically allocate stock to this build? +
+ +{% if allocations %} + + + + + + + + +{% for item in allocations %} + + + + + + +{% endfor %} +
PartQuantityLocation
+ + + + + + {{ item.stock_item.part.name }}
+ {{ item.stock_item.part.description }} +
{{ item.quantity }}{{ item.stock_item.location }}
+ +{% else %} +No stock could be selected for automatic build allocation. +{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/build/templates/build/complete.html b/InvenTree/build/templates/build/complete.html index 506f766c44..a2ebb26209 100644 --- a/InvenTree/build/templates/build/complete.html +++ b/InvenTree/build/templates/build/complete.html @@ -7,7 +7,7 @@ Are you sure you want to mark this build as complete?
{% if taking %} The following items will be removed from stock: -
    +
      {% for item in taking %}
    • {{ item.quantity }} x {{ item.stock_item.part.name }} from {{ item.stock_item.location }}
    • {% endfor %} diff --git a/InvenTree/build/urls.py b/InvenTree/build/urls.py index 162b9a613f..ed0ee63289 100644 --- a/InvenTree/build/urls.py +++ b/InvenTree/build/urls.py @@ -21,6 +21,7 @@ build_detail_urls = [ url(r'^allocate/?', views.BuildAllocate.as_view(), name='build-allocate'), url(r'^cancel/?', views.BuildCancel.as_view(), name='build-cancel'), url(r'^complete/?', views.BuildComplete.as_view(), name='build-complete'), + url(r'^auto-allocate/?', views.BuildAutoAllocate.as_view(), name='build-auto-allocate'), url(r'^.*$', views.BuildDetail.as_view(), name='build-detail'), ] diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index 19af4b6458..6575854704 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -12,7 +12,7 @@ from django.forms import HiddenInput from part.models import Part from .models import Build, BuildItem -from .forms import EditBuildForm, EditBuildItemForm, CompleteBuildForm +from .forms import EditBuildForm, EditBuildItemForm, CompleteBuildForm, AutoAllocateBuildForm from stock.models import StockLocation, StockItem from InvenTree.views import AjaxView, AjaxUpdateView, AjaxCreateView, AjaxDeleteView @@ -67,6 +67,61 @@ class BuildCancel(AjaxView): } +class BuildAutoAllocate(AjaxUpdateView): + """ View to auto-allocate parts for a build. + Follows a simple set of rules to automatically allocate StockItem objects. + + Ref: build.models.Build.getAutoAllocations() + """ + + model = Build + form_class = AutoAllocateBuildForm + context_object_name = 'build' + ajax_form_title = 'Allocate Stock' + ajax_template_name = 'build/auto_allocate.html' + + def get_context_data(self, *args, **kwargs): + """ Get the context data for form rendering. """ + + context = {} + + try: + build = Build.objects.get(id=self.kwargs['pk']) + context['build'] = build + context['allocations'] = build.getAutoAllocations() + except Build.DoesNotExist: + context['error'] = 'No matching buidl found' + + return context + + def post(self, request, *args, **kwargs): + """ Handle POST request. Perform auto allocations. + + - If the form validation passes, perform allocations + - Otherwise, the form is passed back to the client + """ + + build = self.get_object() + form = self.get_form() + + confirm = request.POST.get('confirm', False) + + valid = False + + if confirm is False: + form.errors['confirm'] = ['Confirm stock allocation'] + form.non_field_errors = 'Check the confirmation box at the bottom of the list' + else: + build.autoAllocate() + valid = True + + data = { + 'form_valid': valid, + } + + return self.renderJsonResponse(request, form, data, context=self.get_context_data()) + + class BuildComplete(AjaxUpdateView): """ View to mark a build as Complete. From 345913bc90a1b6c11d37ba80d89d098e034b3259 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 9 May 2019 23:59:39 +1000 Subject: [PATCH 05/10] Improve rendering of 'Complete Build' form --- InvenTree/build/templates/build/complete.html | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/InvenTree/build/templates/build/complete.html b/InvenTree/build/templates/build/complete.html index a2ebb26209..5e9338d656 100644 --- a/InvenTree/build/templates/build/complete.html +++ b/InvenTree/build/templates/build/complete.html @@ -7,18 +7,42 @@ Are you sure you want to mark this build as complete?
      {% if taking %} The following items will be removed from stock: -
        + + + + + + + + {% for item in taking %} -
      • {{ item.quantity }} x {{ item.stock_item.part.name }} from {{ item.stock_item.location }}
      • + + + + + + {% endfor %} - +
        PartQuantityLocation
        + + + + + + {{ item.stock_item.part.name }}
        + {{ item.stock_item.part.description }} +
        {{ item.quantity }}{{ item.stock_item.location }}
        {% else %} No parts have been allocated to this build. {% endif %}
        The following items will be created: -
          -
        • {{ build.quantity }} x {{ build.part.name }}
        • -
        +
        + + + + + {{ build.quantity }} x {{ build.part.name }} +
        {% endblock %} \ No newline at end of file From 3543bd0b63b257a2073bb45a7c7a983bf3a50214 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 10 May 2019 07:40:08 +1000 Subject: [PATCH 06/10] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 502701623e..a47412776f 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ # InvenTree InvenTree is an open-source Inventory Management System which provides powerful low-level stock control and part tracking. The core of the InvenTree system is a Python/Django database backend which provides an admin interface (web-based) and a JSON API for interaction with external interfaces and applications. -InvenTree is designed to be lightweight and easy to use for SME or hobbyist applications, where many existing stock management solutions are bloated and cumbersome to use. Updating stock is a single-action procses and does not require a complex system of work orders or stock transactions. +InvenTree is designed to be lightweight and easy to use for SME or hobbyist applications, where many existing stock management solutions are bloated and cumbersome to use. Updating stock is a single-action process and does not require a complex system of work orders or stock transactions. -However, complex business logic works in the background to ensure that stock tracking history is maintained, and users have ready access to stock level information. +However, powerful business logic works in the background to ensure that stock tracking history is maintained, and users have ready access to stock level information. ## User Documentation From 05f5aa27c53a28b2060aab219d9c188f02cb4da2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 10 May 2019 08:33:54 +1000 Subject: [PATCH 07/10] Add a 'Remove build allocation' function - Removes all parts allocated to a given build --- InvenTree/build/forms.py | 4 +- InvenTree/build/models.py | 6 +++ InvenTree/build/templates/build/allocate.html | 12 ++++- .../build/templates/build/unallocate.html | 9 ++++ InvenTree/build/urls.py | 1 + InvenTree/build/views.py | 48 ++++++++++++++++--- 6 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 InvenTree/build/templates/build/unallocate.html diff --git a/InvenTree/build/forms.py b/InvenTree/build/forms.py index d46138cd09..57c31ff1db 100644 --- a/InvenTree/build/forms.py +++ b/InvenTree/build/forms.py @@ -27,10 +27,10 @@ class EditBuildForm(HelperForm): ] -class AutoAllocateBuildForm(HelperForm): +class ConfirmBuildForm(HelperForm): """ Form for auto-allocation of stock to a build """ - confirm = forms.BooleanField(required=False, help_text='Confirm stock allocation') + confirm = forms.BooleanField(required=False, help_text='Confirm') class Meta: model = Build diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 2c9077f3d7..0b658dee1a 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -165,6 +165,12 @@ class Build(models.Model): return allocations + @transaction.atomic + def unallocateStock(self): + """ Deletes all stock allocations for this build. """ + + BuildItem.objects.filter(build=self.id).delete() + @transaction.atomic def autoAllocate(self): """ Run auto-allocation routine to allocate StockItems to this Build. diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index b3d7dd1009..c58bc39b49 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -19,7 +19,8 @@ InvenTree | Allocate Parts
        - + +
        @@ -74,4 +75,13 @@ InvenTree | Allocate Parts ); }); + $('#unallocate-build').on('click', function() { + launchModalForm( + "{% url 'build-unallocate' build.id %}", + { + reload: true, + } + ); + }); + {% endblock %} diff --git a/InvenTree/build/templates/build/unallocate.html b/InvenTree/build/templates/build/unallocate.html new file mode 100644 index 0000000000..503bc354f6 --- /dev/null +++ b/InvenTree/build/templates/build/unallocate.html @@ -0,0 +1,9 @@ +{% extends "modal_form.html" %} + +{% block pre_form_content %} + +{{ block.super }} + +Are you sure you wish to unallocate all stock for this build? + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/build/urls.py b/InvenTree/build/urls.py index ed0ee63289..3118bd6042 100644 --- a/InvenTree/build/urls.py +++ b/InvenTree/build/urls.py @@ -22,6 +22,7 @@ build_detail_urls = [ url(r'^cancel/?', views.BuildCancel.as_view(), name='build-cancel'), url(r'^complete/?', views.BuildComplete.as_view(), name='build-complete'), url(r'^auto-allocate/?', views.BuildAutoAllocate.as_view(), name='build-auto-allocate'), + url(r'^unallocate/', views.BuildUnallocate.as_view(), name='build-unallocate'), url(r'^.*$', views.BuildDetail.as_view(), name='build-detail'), ] diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index 6575854704..79e3819df5 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -12,7 +12,7 @@ from django.forms import HiddenInput from part.models import Part from .models import Build, BuildItem -from .forms import EditBuildForm, EditBuildItemForm, CompleteBuildForm, AutoAllocateBuildForm +from . import forms from stock.models import StockLocation, StockItem from InvenTree.views import AjaxView, AjaxUpdateView, AjaxCreateView, AjaxDeleteView @@ -75,7 +75,7 @@ class BuildAutoAllocate(AjaxUpdateView): """ model = Build - form_class = AutoAllocateBuildForm + form_class = forms.ConfirmBuildForm context_object_name = 'build' ajax_form_title = 'Allocate Stock' ajax_template_name = 'build/auto_allocate.html' @@ -122,6 +122,40 @@ class BuildAutoAllocate(AjaxUpdateView): return self.renderJsonResponse(request, form, data, context=self.get_context_data()) +class BuildUnallocate(AjaxUpdateView): + """ View to un-allocate all parts from a build. + + Provides a simple confirmation dialog with a BooleanField checkbox. + """ + + model = Build + form_class = forms.ConfirmBuildForm + ajax_form_title = "Unallocate Stock" + ajax_template_name = "build/unallocate.html" + + def post(self, request, *args, **kwargs): + + build = self.get_object() + form = self.get_form() + + confirm = request.POST.get('confirm', False) + + valid = False + + if confirm is False: + form.errors['confirm'] = ['Confirm unallocation of build stock'] + form.non_field_errors = 'Check the confirmation box' + else: + build.unallocateStock() + valid = True + + data = { + 'form_valid': valid, + } + + return self.renderJsonResponse(request, form, data) + + class BuildComplete(AjaxUpdateView): """ View to mark a build as Complete. @@ -131,7 +165,7 @@ class BuildComplete(AjaxUpdateView): """ model = Build - form_class = CompleteBuildForm + form_class = forms.CompleteBuildForm context_object_name = "build" ajax_form_title = "Complete Build" ajax_template_name = "build/complete.html" @@ -248,7 +282,7 @@ class BuildCreate(AjaxCreateView): """ View to create a new Build object """ model = Build context_object_name = 'build' - form_class = EditBuildForm + form_class = forms.EditBuildForm ajax_form_title = 'Start new Build' ajax_template_name = 'modal_form.html' @@ -280,7 +314,7 @@ class BuildUpdate(AjaxUpdateView): """ View for editing a Build object """ model = Build - form_class = EditBuildForm + form_class = forms.EditBuildForm context_object_name = 'build' ajax_form_title = 'Edit Build Details' ajax_template_name = 'modal_form.html' @@ -311,7 +345,7 @@ class BuildItemCreate(AjaxCreateView): """ View for allocating a new part to a build """ model = BuildItem - form_class = EditBuildItemForm + form_class = forms.EditBuildItemForm ajax_template_name = 'modal_form.html' ajax_form_title = 'Allocate new Part' @@ -397,7 +431,7 @@ class BuildItemEdit(AjaxUpdateView): model = BuildItem ajax_template_name = 'modal_form.html' - form_class = EditBuildItemForm + form_class = forms.EditBuildItemForm ajax_form_title = 'Edit Stock Allocation' def get_data(self): From b377efbbec65f722b318351ba38216aad20f7f51 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 10 May 2019 08:36:08 +1000 Subject: [PATCH 08/10] Replaced button text with icons --- InvenTree/static/script/inventree/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/static/script/inventree/build.js b/InvenTree/static/script/inventree/build.js index 826e2b1661..b92b033049 100644 --- a/InvenTree/static/script/inventree/build.js +++ b/InvenTree/static/script/inventree/build.js @@ -40,8 +40,8 @@ function loadAllocationTable(table, part_id, part, url, required, button) { formatter: function(value, row, index, field) { var html = value; - var bEdit = ""; - var bDel = ""; + var bEdit = ""; + var bDel = ""; html += "
        " + bEdit + bDel + "
        "; From 932c07287b61117f48b601a38b347e951a5d68ef Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 10 May 2019 08:38:17 +1000 Subject: [PATCH 09/10] Button fixes --- InvenTree/part/templates/part/attachments.html | 4 ++-- InvenTree/static/script/inventree/bom.js | 2 +- InvenTree/static/script/inventree/build.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/InvenTree/part/templates/part/attachments.html b/InvenTree/part/templates/part/attachments.html index 77ffa8dbff..e3bed202c4 100644 --- a/InvenTree/part/templates/part/attachments.html +++ b/InvenTree/part/templates/part/attachments.html @@ -30,8 +30,8 @@ {{ attachment.comment }}
        - - + +
        diff --git a/InvenTree/static/script/inventree/bom.js b/InvenTree/static/script/inventree/bom.js index e88e617945..762c6b1d6b 100644 --- a/InvenTree/static/script/inventree/bom.js +++ b/InvenTree/static/script/inventree/bom.js @@ -129,7 +129,7 @@ function loadBomTable(table, options) { if (options.editable) { cols.push({ formatter: function(value, row, index, field) { - var bEdit = ""; + var bEdit = ""; var bDelt = ""; return "
        " + bEdit + bDelt + "
        "; diff --git a/InvenTree/static/script/inventree/build.js b/InvenTree/static/script/inventree/build.js index b92b033049..4ecd4214a2 100644 --- a/InvenTree/static/script/inventree/build.js +++ b/InvenTree/static/script/inventree/build.js @@ -40,7 +40,7 @@ function loadAllocationTable(table, part_id, part, url, required, button) { formatter: function(value, row, index, field) { var html = value; - var bEdit = ""; + var bEdit = ""; var bDel = ""; html += "
        " + bEdit + bDel + "
        "; From 66b729d579e7b6461c99dc9c6ff6f5ad915cb4a0 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 10 May 2019 08:44:07 +1000 Subject: [PATCH 10/10] Moved 'complete build' button to the build detail page --- InvenTree/build/templates/build/allocate.html | 11 ----------- InvenTree/build/templates/build/detail.html | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index c58bc39b49..15061a18b4 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -20,7 +20,6 @@ InvenTree | Allocate Parts
        -
        @@ -56,16 +55,6 @@ InvenTree | Allocate Parts {% endfor %} - $("#complete-build").on('click', function() { - launchModalForm( - "{% url 'build-complete' build.id %}", - { - reload: true, - submit_text: "Complete Build", - } - ); - }); - $("#auto-allocate-build").on('click', function() { launchModalForm( "{% url 'build-auto-allocate' build.id %}", diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 8beeb6ac08..fef67f77c1 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -17,12 +17,15 @@ InvenTree | Build - {{ build }}