diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index f7bf9acc3f..7bb40f7269 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -81,7 +81,8 @@ class SupplierPartList(generics.ListCreateAPIView): 'part__stock_items', 'part__bom_items', 'part__builds', - 'supplier') + 'supplier', + 'pricebreaks') serializer_class = SupplierPartSerializer @@ -151,7 +152,7 @@ supplier_part_api_urls = [ company_api_urls = [ - url(r'^part/', include(supplier_part_api_urls)), + url(r'^part/?', include(supplier_part_api_urls)), url(r'^price-break/?', SupplierPriceBreakList.as_view(), name='api-part-supplier-price'), diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index 5c3b3291ff..be59c2b66f 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -239,6 +239,10 @@ class SupplierPart(models.Model): """ Return the associated price breaks in the correct order """ return self.pricebreaks.order_by('quantity').all() + @property + def unit_pricing(self): + return self.get_price(1) + def get_price(self, quantity, moq=True, multiples=True): """ Calculate the supplier price based on quantity price breaks. diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py index b09bccd234..5d1ac2ba9d 100644 --- a/InvenTree/company/serializers.py +++ b/InvenTree/company/serializers.py @@ -33,7 +33,7 @@ class CompanySerializer(serializers.ModelSerializer): class Meta: model = Company fields = [ - 'id', + 'pk', 'url', 'name', 'description', @@ -62,6 +62,8 @@ class SupplierPartSerializer(serializers.ModelSerializer): supplier_name = serializers.CharField(source='supplier.name', read_only=True) supplier_logo = serializers.CharField(source='supplier.get_image_url', read_only=True) + pricing = serializers.CharField(source='unit_pricing', read_only=True) + class Meta: model = SupplierPart fields = [ @@ -76,6 +78,7 @@ class SupplierPartSerializer(serializers.ModelSerializer): 'manufacturer', 'MPN', 'URL', + 'pricing', ] diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 787e071036..b561d08ae5 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -33,33 +33,39 @@
- + {% if part.IPN %} - + {% endif %} + {% if part.variant %} - + + + + {% endif %} + + {% if part.keywords %} - + {% endif %} {% if part.URL %} - + {% endif %} - + {% if part.default_location %} - + {% endif %} {% if part.default_supplier %} - + {% endif %} - +
Part namePart name {{ part.full_name }}
IPNIPN {{ part.IPN }}
DescriptionVariant{{ part.variant }}
Description {{ part.description }}
KeywordsKeywords {{ part.keywords }}
URLURL {{ part.URL }}
CategoryCategory {% if part.category %} {{ part.category.pathstring }} @@ -68,20 +74,20 @@
Default LocationDefault Location {{ part.default_location.pathstring }}
Default SupplierDefault Supplier {{ part.default_supplier.supplier.name }} | {{ part.default_supplier.SKU }}
UnitsUnits {{ part.units }}
@@ -89,28 +95,28 @@
- + - + - + - + - + {% if part.minimum_stock > 0 %} - + {% endif %} diff --git a/InvenTree/part/templates/part/part_pricing.html b/InvenTree/part/templates/part/part_pricing.html index 6d82549bb2..55d68f06e2 100644 --- a/InvenTree/part/templates/part/part_pricing.html +++ b/InvenTree/part/templates/part/part_pricing.html @@ -3,7 +3,8 @@ {% block pre_form_content %}
-Calculate pricing information for {{ part }}. +Pricing information for:
+{{ part }}.

Quantity

diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html index 68b89bf1b9..93c3be29f8 100644 --- a/InvenTree/part/templates/part/stock.html +++ b/InvenTree/part/templates/part/stock.html @@ -57,6 +57,15 @@ title: 'Create New Part', url: "{% url 'part-create' %}", }, + { + field: 'supplier_part', + label: 'New Supplier Part', + title: 'Create new Supplier Part', + url: "{% url 'supplier-part-create' %}", + data: { + part: {{ part.id }} + }, + }, { field: 'location', label: 'New Location', diff --git a/InvenTree/part/templates/part/supplier.html b/InvenTree/part/templates/part/supplier.html index 041d1fd8c7..ea5baa2759 100644 --- a/InvenTree/part/templates/part/supplier.html +++ b/InvenTree/part/templates/part/supplier.html @@ -38,11 +38,21 @@ $('#supplier-create').click(function () { launchModalForm( - "{% url 'supplier-part-create' %}", - { - reload: true, - data: {part: {{ part.id }} } - }); + "{% url 'supplier-part-create' %}", + { + reload: true, + data: { + part: {{ part.id }} + }, + secondary: [ + { + field: 'supplier', + label: 'New Supplier', + title: 'Create new supplier', + url: "{% url 'company-create' %}" + } + ] + }); }); $("#supplier-table").bootstrapTable({ @@ -83,6 +93,18 @@ sortable: true, field: 'MPN', title: 'MPN', + }, + { + sortable: true, + field: 'pricing', + title: 'Price', + formatter: function(value, row, index, field) { + if (value) { + return value; + } else { + return "No pricing available"; + } + }, } ], url: "{% url 'api-part-supplier-list' %}" diff --git a/InvenTree/static/css/inventree.css b/InvenTree/static/css/inventree.css index ff7ac4e98b..f4d4bdd26a 100644 --- a/InvenTree/static/css/inventree.css +++ b/InvenTree/static/css/inventree.css @@ -226,6 +226,10 @@ padding-bottom: 3px; } +.modal .btn-secondary { + background-color: #5e7d87; +} + /* The side navigation menu */ .sidenav { height: 100%; /* 100% Full-height */ diff --git a/InvenTree/static/script/inventree/modals.js b/InvenTree/static/script/inventree/modals.js index afb14ace9f..7d55d02865 100644 --- a/InvenTree/static/script/inventree/modals.js +++ b/InvenTree/static/script/inventree/modals.js @@ -362,7 +362,7 @@ function insertNewItemButton(modal, options) { var html = ""; - html += "
BuildableBuildable {% include "yesnolabel.html" with value=part.buildable %}
ConsumableConsumable {% include "yesnolabel.html" with value=part.consumable %}
TrackableTrackable {% include "yesnolabel.html" with value=part.trackable %}
PurchaseablePurchaseable {% include "yesnolabel.html" with value=part.purchaseable %}
SalableSalable {% include "yesnolabel.html" with value=part.salable %}
Minimum StockMinimum Stock {{ part.minimum_stock }}