From fedbb834ee1a1e1dd82aa09d1d4ff71b1d69fe69 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 16 Sep 2019 08:17:39 +1000 Subject: [PATCH 01/11] Add mouse-over text to build-cancel button --- InvenTree/build/templates/build/build_base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index 3e4ee98cd5..3ab3fc05c0 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -34,7 +34,7 @@ InvenTree | Build - {{ build }} - {% endif %} From 628a58e8fcf07941c20e63dd362740f705087438 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 16 Sep 2019 08:23:40 +1000 Subject: [PATCH 02/11] Show which parts are short in build view --- InvenTree/InvenTree/static/css/inventree.css | 4 ++-- InvenTree/InvenTree/static/script/inventree/bom.js | 4 ++-- InvenTree/build/templates/build/allocate_view.html | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 2f54a50219..812c0ffa51 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -98,11 +98,11 @@ max-width: 250px; } -.bomrowvalid { +.rowvalid { color: #050; } -.bomrowinvalid { +.rowinvalid { color: #A00; font-style: italic; } diff --git a/InvenTree/InvenTree/static/script/inventree/bom.js b/InvenTree/InvenTree/static/script/inventree/bom.js index aa64a776f5..97dca94017 100644 --- a/InvenTree/InvenTree/static/script/inventree/bom.js +++ b/InvenTree/InvenTree/static/script/inventree/bom.js @@ -280,9 +280,9 @@ function loadBomTable(table, options) { search: true, rowStyle: function(row, index) { if (row.validated) { - return {classes: 'bomrowvalid'}; + return {classes: 'rowvalid'}; } else { - return {classes: 'bomrowinvalid'}; + return {classes: 'rowinvalid'}; } }, formatNoMatches: function() { return "No BOM items found"; }, diff --git a/InvenTree/build/templates/build/allocate_view.html b/InvenTree/build/templates/build/allocate_view.html index c688171f7e..f5f3952546 100644 --- a/InvenTree/build/templates/build/allocate_view.html +++ b/InvenTree/build/templates/build/allocate_view.html @@ -21,7 +21,7 @@ {% for item in build.required_parts %} - + {% include "hover_image.html" with image=item.part.image hover=True %} {{ item.part.full_name }} From 55ebf486848f8fe327ebd9ce7666b9333e4a6e30 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 16 Sep 2019 09:43:57 +1000 Subject: [PATCH 03/11] Add more export fields for SupplierPart and SupplierPriceBreak --- InvenTree/company/admin.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/InvenTree/company/admin.py b/InvenTree/company/admin.py index ce023aedc0..f69bfec54f 100644 --- a/InvenTree/company/admin.py +++ b/InvenTree/company/admin.py @@ -38,8 +38,12 @@ class SupplierPartResource(ModelResource): part = Field(attribute='part', widget=widgets.ForeignKeyWidget(Part)) + part_name = Field(attribute='part__full_name', readonly=True) + supplier = Field(attribute='supplier', widget=widgets.ForeignKeyWidget(Company)) + supplier_name = Field(attribute='supplier__name', readonly=True) + class Meta: model = SupplierPart skip_unchanged = True @@ -61,6 +65,16 @@ class SupplierPriceBreakResource(ModelResource): currency = Field(attribute='currency', widget=widgets.ForeignKeyWidget(Currency)) + supplier_id = Field(attribute='part__supplier__pk', readonly=True) + + supplier_name = Field(attribute='part__supplier__name', readonly=True) + + part_name = Field(attribute='part__part__full_name', readonly=True) + + SKU = Field(attribute='part__SKU', readonly=True) + + MPN = Field(attribute='part__MPN', readonly=True) + class Meta: model = SupplierPriceBreak skip_unchanged = True From a9d1cadc123e1bb1baf23ef2944d43381f936e08 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 Sep 2019 00:41:28 +1000 Subject: [PATCH 04/11] Add link to documentation --- InvenTree/part/templatetags/inventree_extras.py | 8 +++++++- InvenTree/templates/about.html | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index c51d07fdd5..14a884c2b7 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -46,6 +46,12 @@ def inventree_commit(*args, **kwargs): @register.simple_tag() -def inventree_github(*args, **kwargs): +def inventree_github_url(*args, **kwargs): """ Return URL for InvenTree github site """ return "https://github.com/InvenTree" + + +@register.simple_tag() +def inventree_docs_url(*args, **kwargs): + """ Return URL for InvenTree documenation site """ + return "https://inventree.github.io" diff --git a/InvenTree/templates/about.html b/InvenTree/templates/about.html index aef286f6cf..7e2abeb788 100644 --- a/InvenTree/templates/about.html +++ b/InvenTree/templates/about.html @@ -26,7 +26,11 @@ - View Code on GitHub{% inventree_github %} + InvenTree Documenation + {% inventree_docs_url %} + + + View Code on GitHub{% inventree_github_url %} From d40fc59616865bb8f0dc0e86f510eff82588255b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 Sep 2019 10:34:41 +1000 Subject: [PATCH 05/11] Reload page after ordering part --- InvenTree/InvenTree/static/css/inventree.css | 8 ++++++++ InvenTree/part/templates/part/orders.html | 7 ++++--- InvenTree/part/templates/part/part_base.html | 8 ++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 812c0ffa51..579803410b 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -1,3 +1,11 @@ +:root { + --primary-color: #335d88; + --secondary-color: #b69c80; + --highlight-color: #f5efe8; + --basic-color: #333; +} + + .qr-code { max-width: 400px; max-height: 400px; diff --git a/InvenTree/part/templates/part/orders.html b/InvenTree/part/templates/part/orders.html index 975a41049a..d3488bea2d 100644 --- a/InvenTree/part/templates/part/orders.html +++ b/InvenTree/part/templates/part/orders.html @@ -10,7 +10,7 @@
- +
@@ -31,11 +31,12 @@ $("#po-table").bootstrapTable({ sortable: true, }); -$("#part-order-2").click(function() { - launchModalForm("/order/purchase-order/order-parts/", { +$("#part-order2").click(function() { + launchModalForm("{% url 'order-parts' %}", { data: { part: {{ part.id }}, }, + reload: true, }); }); diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 8cbae62fec..dfb9b2decf 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -184,8 +184,8 @@ data: { action: "count", part: {{ part.id }}, - reload: true, - } + }, + reload: true, }); }); @@ -225,10 +225,10 @@ }); $("#part-order").click(function() { - launchModalForm("/order/purchase-order/order-parts/", { + launchModalForm("{% url 'order-parts' %}", { data: { part: {{ part.id }}, - }, + } }); }); From 1cffd41c078dec7e4ba47b55e3a52294da9c4424 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 Sep 2019 10:54:28 +1000 Subject: [PATCH 06/11] Fix broken price-break buttons - Did not work! --- InvenTree/company/templates/company/partdetail.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/company/templates/company/partdetail.html b/InvenTree/company/templates/company/partdetail.html index c3dd3a50d6..77d71ea77c 100644 --- a/InvenTree/company/templates/company/partdetail.html +++ b/InvenTree/company/templates/company/partdetail.html @@ -93,8 +93,8 @@ InvenTree | {{ company.name }} - Parts {{ pb.cost }} {% if pb.currency %}{{ pb.currency.suffix }}{% endif %}
- - + +
From f90aa1d2cf17809bbe9f33506063610d98346ca3 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 Sep 2019 11:44:50 +1000 Subject: [PATCH 07/11] Make purchase-order table sortable --- InvenTree/order/templates/order/po_table.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/InvenTree/order/templates/order/po_table.html b/InvenTree/order/templates/order/po_table.html index 32b5d4e80c..16fa462951 100644 --- a/InvenTree/order/templates/order/po_table.html +++ b/InvenTree/order/templates/order/po_table.html @@ -1,11 +1,11 @@ - - - - - + + + + + From b5b7dc0fbfaf991fd8bcc10eaeaee15168b3233d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 Sep 2019 12:29:18 +1000 Subject: [PATCH 08/11] Fix tests --- InvenTree/part/test_part.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/test_part.py b/InvenTree/part/test_part.py index 84d9900aff..46eb484b12 100644 --- a/InvenTree/part/test_part.py +++ b/InvenTree/part/test_part.py @@ -26,7 +26,10 @@ class TemplateTagTest(TestCase): self.assertEqual(len(hash), 7) def test_github(self): - self.assertIn('github.com', inventree_extras.inventree_github()) + self.assertIn('github.com', inventree_extras.inventree_github_url()) + + def test_docs(self): + self.assertIn('inventree.github.io', inventree_extras.inventree_docs_url()) class PartTest(TestCase): From 94cd28ecb90627fd8e14f1da9dee23760570cc80 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 Sep 2019 13:49:57 +1000 Subject: [PATCH 09/11] Add ability so set category for multiple parts at once --- InvenTree/part/templates/part/category.html | 1 + InvenTree/part/templates/part/set_category.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 26098be946..d9913482fd 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -49,6 +49,7 @@
CompanyOrder ReferenceDescriptionStatusItemsCompanyOrder ReferenceDescriptionStatusItems
- {% for part in parts %} - - - - - - - - {% endfor %} -
Part Description Category -
- {% include "hover_image.html" with image=part.image hover=False %} - {{ part.full_name }} - - {{ part.description }} - - {{ part.category.pathstring }} - - -
- - -{% endblock %} \ No newline at end of file + + {% for part in parts %} + + + + {% include "hover_image.html" with image=part.image hover=False %} + {{ part.full_name }} + + + {{ part.description }} + + + {{ part.category.pathstring }} + + + + + + {% endfor %} + + + {% crispy form %} + + + {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 7d1a3ab633..87a3959266 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -138,11 +138,12 @@ class PartAttachmentDelete(AjaxDeleteView): } -class PartSetCategory(AjaxView): +class PartSetCategory(AjaxUpdateView): """ View for settings the part category for multiple parts at once """ ajax_template_name = 'part/set_category.html' ajax_form_title = 'Set Part Category' + form_class = part_forms.SetPartCategoryForm category = None parts = [] @@ -157,7 +158,7 @@ class PartSetCategory(AjaxView): else: self.parts = [] - return self.renderJsonResponse(request, context=self.get_context_data()) + return self.renderJsonResponse(request, form=self.get_form(), context=self.get_context_data()) def post(self, request, *args, **kwargs): """ Respond to a POST request to this view """ @@ -196,7 +197,7 @@ class PartSetCategory(AjaxView): for part in self.parts: part.set_category(self.category) - return self.renderJsonResponse(request, data=data, context=self.get_context_data()) + return self.renderJsonResponse(request, data=data, form=self.get_form(), context=self.get_context_data()) def get_context_data(self): """ Return context data for rendering in the form """ From 774872e6a600e70bf54bea808caede98f0a9c7f1 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 Sep 2019 14:17:49 +1000 Subject: [PATCH 11/11] Make function atomic --- InvenTree/part/views.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 87a3959266..a736b9275e 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -6,6 +6,7 @@ Django views for interacting with Part app from __future__ import unicode_literals from django.core.exceptions import ValidationError +from django.db import transaction from django.shortcuts import get_object_or_404 from django.shortcuts import HttpResponseRedirect from django.utils.translation import gettext_lazy as _ @@ -194,11 +195,15 @@ class PartSetCategory(AjaxUpdateView): } if valid: - for part in self.parts: - part.set_category(self.category) + self.set_category() return self.renderJsonResponse(request, data=data, form=self.get_form(), context=self.get_context_data()) + @transaction.atomic + def set_category(self): + for part in self.parts: + part.set_category(self.category) + def get_context_data(self): """ Return context data for rendering in the form """ ctx = {}