From 205567cfb4e62ce8483f4ad132c777acba4146da Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 13 Sep 2019 15:47:34 +1000 Subject: [PATCH 1/3] cd to the correct directory to run the dev server --- docs/start.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/start.rst b/docs/start.rst index 30ac87ad17..a5621d9f97 100644 --- a/docs/start.rst +++ b/docs/start.rst @@ -70,7 +70,7 @@ Create an initial superuser (administrator) account for the InvenTree instance: Run Development Server ---------------------- -Run ``python3 InvenTree/manage.py runserver 127.0.0.1:8000`` to launch a development server. This will launch the InvenTree web interface at ``127.0.0.1:8000``. For other options refer to the `django docs `_. +Run ``cd InvenTree && python3 manage.py runserver 127.0.0.1:8000`` to launch a development server. This will launch the InvenTree web interface at ``127.0.0.1:8000``. For other options refer to the `django docs `_. Database Migrations ------------------- From 8fcc1b84481d7c9eef2f90e433cb1c5971f628b2 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 13 Sep 2019 15:54:12 +1000 Subject: [PATCH 2/3] Update version.py Bumped to v0.0.6 --- InvenTree/InvenTree/version.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index 1766168a30..0bb8a82d6f 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -4,7 +4,7 @@ Provides information on the current InvenTree version import subprocess -INVENTREE_SW_VERSION = "0.0.5" +INVENTREE_SW_VERSION = "0.0.6" def inventreeVersion(): @@ -15,7 +15,6 @@ def inventreeVersion(): def inventreeCommitHash(): """ Returns the git commit hash for the running codebase """ - # TODO - This doesn't seem to work when running under gunicorn. Why is this?! commit = str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip() return commit From 567826165c48d4a14c8f0eff025162e73fb2a017 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 13 Sep 2019 16:26:44 +1000 Subject: [PATCH 3/3] Improve BomItem editing form - Don't allow duplication of an item already in the BOM - Remove the parent part from the BOM --- InvenTree/part/views.py | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 59f04de830..7f66cd7718 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -1741,7 +1741,7 @@ class BomItemCreate(AjaxCreateView): form.fields['part'].widget = HiddenInput() - except Part.DoesNotExist: + except (ValueError, Part.DoesNotExist): pass return form @@ -1775,6 +1775,46 @@ class BomItemEdit(AjaxUpdateView): ajax_template_name = 'modal_form.html' ajax_form_title = 'Edit BOM item' + def get_form(self): + """ Override get_form() method to filter part selection options + + - Do not allow part to be added to its own BOM + - Remove any part items that are already in the BOM + """ + + form = super().get_form() + + part_id = form['part'].value() + + try: + part = Part.objects.get(pk=part_id) + + query = form.fields['sub_part'].queryset + + # Reduce the available selection options + query = query.exclude(pk=part_id) + + # Eliminate any options that are already in the BOM, + # *except* for the item which is already selected + try: + sub_part_id = int(form['sub_part'].value()) + except ValueError: + sub_part_id = -1 + + existing = [item.pk for item in part.required_parts()] + + if sub_part_id in existing: + existing.remove(sub_part_id) + + query = query.exclude(id__in=existing) + + form.fields['sub_part'].queryset = query + + except (ValueError, Part.DoesNotExist): + pass + + return form + class BomItemDelete(AjaxDeleteView): """ Delete view for removing BomItem """