mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +00:00
Include pricing information in part supplier view
Also some CSS tweaks to secondary modal buttons
This commit is contained in:
parent
49425efef9
commit
cd7bc6cce5
@ -81,7 +81,8 @@ class SupplierPartList(generics.ListCreateAPIView):
|
|||||||
'part__stock_items',
|
'part__stock_items',
|
||||||
'part__bom_items',
|
'part__bom_items',
|
||||||
'part__builds',
|
'part__builds',
|
||||||
'supplier')
|
'supplier',
|
||||||
|
'pricebreaks')
|
||||||
|
|
||||||
serializer_class = SupplierPartSerializer
|
serializer_class = SupplierPartSerializer
|
||||||
|
|
||||||
|
@ -239,6 +239,10 @@ class SupplierPart(models.Model):
|
|||||||
""" Return the associated price breaks in the correct order """
|
""" Return the associated price breaks in the correct order """
|
||||||
return self.pricebreaks.order_by('quantity').all()
|
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):
|
def get_price(self, quantity, moq=True, multiples=True):
|
||||||
""" Calculate the supplier price based on quantity price breaks.
|
""" Calculate the supplier price based on quantity price breaks.
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
|||||||
supplier_name = serializers.CharField(source='supplier.name', read_only=True)
|
supplier_name = serializers.CharField(source='supplier.name', read_only=True)
|
||||||
supplier_logo = serializers.CharField(source='supplier.get_image_url', 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:
|
class Meta:
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
fields = [
|
fields = [
|
||||||
@ -76,6 +78,7 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
|||||||
'manufacturer',
|
'manufacturer',
|
||||||
'MPN',
|
'MPN',
|
||||||
'URL',
|
'URL',
|
||||||
|
'pricing',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
{% block pre_form_content %}
|
{% block pre_form_content %}
|
||||||
|
|
||||||
<div class='alert alert-info alert-block'>
|
<div class='alert alert-info alert-block'>
|
||||||
Calculate pricing information for {{ part }}.
|
Pricing information for:<br>
|
||||||
|
{{ part }}.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4>Quantity</h4>
|
<h4>Quantity</h4>
|
||||||
|
@ -57,6 +57,15 @@
|
|||||||
title: 'Create New Part',
|
title: 'Create New Part',
|
||||||
url: "{% url 'part-create' %}",
|
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',
|
field: 'location',
|
||||||
label: 'New Location',
|
label: 'New Location',
|
||||||
|
@ -38,11 +38,21 @@
|
|||||||
|
|
||||||
$('#supplier-create').click(function () {
|
$('#supplier-create').click(function () {
|
||||||
launchModalForm(
|
launchModalForm(
|
||||||
"{% url 'supplier-part-create' %}",
|
"{% url 'supplier-part-create' %}",
|
||||||
{
|
{
|
||||||
reload: true,
|
reload: true,
|
||||||
data: {part: {{ part.id }} }
|
data: {
|
||||||
});
|
part: {{ part.id }}
|
||||||
|
},
|
||||||
|
secondary: [
|
||||||
|
{
|
||||||
|
field: 'supplier',
|
||||||
|
label: 'New Supplier',
|
||||||
|
title: 'Create new supplier',
|
||||||
|
url: "{% url 'company-create' %}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#supplier-table").bootstrapTable({
|
$("#supplier-table").bootstrapTable({
|
||||||
@ -83,6 +93,18 @@
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
field: 'MPN',
|
field: 'MPN',
|
||||||
title: 'MPN',
|
title: 'MPN',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortable: true,
|
||||||
|
field: 'pricing',
|
||||||
|
title: 'Price',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
if (value) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return "<span class='warning-msg'><i>No pricing available</i></span>";
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
url: "{% url 'api-part-supplier-list' %}"
|
url: "{% url 'api-part-supplier-list' %}"
|
||||||
|
@ -226,6 +226,10 @@
|
|||||||
padding-bottom: 3px;
|
padding-bottom: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal .btn-secondary {
|
||||||
|
background-color: #5e7d87;
|
||||||
|
}
|
||||||
|
|
||||||
/* The side navigation menu */
|
/* The side navigation menu */
|
||||||
.sidenav {
|
.sidenav {
|
||||||
height: 100%; /* 100% Full-height */
|
height: 100%; /* 100% Full-height */
|
||||||
|
@ -362,7 +362,7 @@ function insertNewItemButton(modal, options) {
|
|||||||
|
|
||||||
var html = "<span style='float: right;'>";
|
var html = "<span style='float: right;'>";
|
||||||
|
|
||||||
html += "<div type='button' class='btn btn-primary'";
|
html += "<div type='button' class='btn btn-primary btn-secondary'";
|
||||||
|
|
||||||
if (options.title) {
|
if (options.title) {
|
||||||
html += " title='" + options.title + "'";
|
html += " title='" + options.title + "'";
|
||||||
@ -392,6 +392,8 @@ function attachSecondaryModal(modal, options) {
|
|||||||
// Insert the button
|
// Insert the button
|
||||||
insertNewItemButton(modal, options);
|
insertNewItemButton(modal, options);
|
||||||
|
|
||||||
|
var data = options.data || {};
|
||||||
|
|
||||||
// Add a callback to the button
|
// Add a callback to the button
|
||||||
$(modal).find("#btn-new-" + options.field).on('click', function() {
|
$(modal).find("#btn-new-" + options.field).on('click', function() {
|
||||||
|
|
||||||
@ -400,6 +402,7 @@ function attachSecondaryModal(modal, options) {
|
|||||||
options.url,
|
options.url,
|
||||||
{
|
{
|
||||||
modal: '#modal-form-secondary',
|
modal: '#modal-form-secondary',
|
||||||
|
data: data,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
|
|
||||||
/* A successful object creation event should return a response which contains:
|
/* A successful object creation event should return a response which contains:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user