mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixed serializers and started update of templates
This commit is contained in:
parent
811f9333e8
commit
9c8817d73b
@ -215,7 +215,7 @@ class SupplierPartList(generics.ListCreateAPIView):
|
|||||||
manufacturer = params.get('manufacturer', None)
|
manufacturer = params.get('manufacturer', None)
|
||||||
|
|
||||||
if manufacturer is not None:
|
if manufacturer is not None:
|
||||||
queryset = queryset.filter(manufacturer=manufacturer)
|
queryset = queryset.filter(manufacturer_part__manufacturer=manufacturer)
|
||||||
|
|
||||||
# Filter by supplier
|
# Filter by supplier
|
||||||
supplier = params.get('supplier', None)
|
supplier = params.get('supplier', None)
|
||||||
@ -227,7 +227,7 @@ class SupplierPartList(generics.ListCreateAPIView):
|
|||||||
company = params.get('company', None)
|
company = params.get('company', None)
|
||||||
|
|
||||||
if company is not None:
|
if company is not None:
|
||||||
queryset = queryset.filter(Q(manufacturer=company) | Q(supplier=company))
|
queryset = queryset.filter(Q(manufacturer_part__manufacturer=company) | Q(supplier=company))
|
||||||
|
|
||||||
# Filter by parent part?
|
# Filter by parent part?
|
||||||
part = params.get('part', None)
|
part = params.get('part', None)
|
||||||
@ -298,7 +298,7 @@ class SupplierPartDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
- GET: Retrieve detail view
|
- GET: Retrieve detail view
|
||||||
- PATCH: Update object
|
- PATCH: Update object
|
||||||
- DELETE: Delete objec
|
- DELETE: Delete object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = SupplierPart.objects.all()
|
queryset = SupplierPart.objects.all()
|
||||||
|
@ -400,7 +400,7 @@ class SupplierPart(models.Model):
|
|||||||
|
|
||||||
manufacturer_part = models.ForeignKey(ManufacturerPart, on_delete=models.CASCADE,
|
manufacturer_part = models.ForeignKey(ManufacturerPart, on_delete=models.CASCADE,
|
||||||
blank=True, null=True,
|
blank=True, null=True,
|
||||||
related_name='manufacturer_parts',
|
related_name='supplier_parts',
|
||||||
verbose_name=_('Manufacturer Part'),
|
verbose_name=_('Manufacturer Part'),
|
||||||
help_text=_('Select manufacturer part'),
|
help_text=_('Select manufacturer part'),
|
||||||
)
|
)
|
||||||
|
@ -82,7 +82,7 @@ class CompanySerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class ManufacturerPartSerializer(InvenTreeModelSerializer):
|
class ManufacturerPartSerializer(InvenTreeModelSerializer):
|
||||||
""" Serializer for SupplierPart object """
|
""" Serializer for ManufacturerPart object """
|
||||||
|
|
||||||
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class SupplierPartSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
supplier_detail = CompanyBriefSerializer(source='supplier', many=False, read_only=True)
|
supplier_detail = CompanyBriefSerializer(source='supplier', many=False, read_only=True)
|
||||||
|
|
||||||
manufacturer_detail = ManufacturerPartSerializer(source='manufacturer_part', many=False, read_only=True)
|
manufacturer_detail = CompanyBriefSerializer(source='manufacturer_part.manufacturer', many=False, read_only=True)
|
||||||
|
|
||||||
pretty_name = serializers.CharField(read_only=True)
|
pretty_name = serializers.CharField(read_only=True)
|
||||||
|
|
||||||
@ -158,9 +158,9 @@ class SupplierPartSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
supplier = serializers.PrimaryKeyRelatedField(queryset=Company.objects.filter(is_supplier=True))
|
supplier = serializers.PrimaryKeyRelatedField(queryset=Company.objects.filter(is_supplier=True))
|
||||||
|
|
||||||
manufacturer = ManufacturerPartSerializer(many=False, read_only=True)
|
manufacturer = serializers.PrimaryKeyRelatedField(source='manufacturer_part.manufacturer', queryset=Company.objects.filter(is_manufacturer=True))
|
||||||
|
|
||||||
MPN = ManufacturerPartSerializer(many=False, read_only=True)
|
MPN = serializers.StringRelatedField(source='manufacturer_part.MPN', read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li class='list-group-item {% if tab == "suppliers" %}active{% endif %}' title='{% trans "Supplier Parts" %}'>
|
||||||
|
<a href='{% url "manufacturer-part-suppliers" part.id %}'>
|
||||||
|
<span class='fas fa-warehouse'></span>
|
||||||
|
{% trans "Suppliers" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
{% comment "for later" %}
|
{% comment "for later" %}
|
||||||
<li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Manufacturer Part Stock" %}'>
|
<li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Manufacturer Part Stock" %}'>
|
||||||
<a href='{% url "manufacturer-part-stock" part.id %}'>
|
<a href='{% url "manufacturer-part-stock" part.id %}'>
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
{% extends "company/manufacturer_part_base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block menubar %}
|
||||||
|
{% include "company/manufacturer_part_navbar.html" with tab='suppliers' %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block heading %}
|
||||||
|
{% trans "Supplier Parts" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block details %}
|
||||||
|
<div id='button-toolbar'>
|
||||||
|
<div class='btn-group'>
|
||||||
|
<button class="btn btn-success" id='supplier-create'>
|
||||||
|
<span class='fas fa-plus-circle'></span> {% trans "New Supplier Part" %}
|
||||||
|
</button>
|
||||||
|
<div id='opt-dropdown' class="btn-group">
|
||||||
|
<button id='supplier-part-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href='#' id='supplier-part-delete' title='{% trans "Delete supplier parts" %}'>{% trans "Delete" %}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="table table-striped table-condensed" id='supplier-table' data-toolbar='#button-toolbar'>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js_ready %}
|
||||||
|
{{ block.super }}
|
||||||
|
|
||||||
|
$('#supplier-create').click(function () {
|
||||||
|
launchModalForm(
|
||||||
|
"{% url 'supplier-part-create' %}",
|
||||||
|
{
|
||||||
|
reload: true,
|
||||||
|
data: {
|
||||||
|
part: {{ part.id }}
|
||||||
|
},
|
||||||
|
secondary: [
|
||||||
|
{
|
||||||
|
field: 'supplier',
|
||||||
|
label: '{% trans "New Supplier" %}',
|
||||||
|
title: '{% trans "Create new supplier" %}',
|
||||||
|
url: "{% url 'supplier-create' %}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'manufacturer',
|
||||||
|
label: '{% trans "New Manufacturer" %}',
|
||||||
|
title: '{% trans "Create new manufacturer" %}',
|
||||||
|
url: "{% url 'manufacturer-create' %}",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#supplier-part-delete").click(function() {
|
||||||
|
|
||||||
|
var selections = $("#supplier-table").bootstrapTable("getSelections");
|
||||||
|
|
||||||
|
var parts = [];
|
||||||
|
|
||||||
|
selections.forEach(function(item) {
|
||||||
|
parts.push(item.pk);
|
||||||
|
});
|
||||||
|
|
||||||
|
launchModalForm("{% url 'supplier-part-delete' %}", {
|
||||||
|
data: {
|
||||||
|
parts: parts,
|
||||||
|
},
|
||||||
|
reload: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
loadSupplierPartTable(
|
||||||
|
"#supplier-table",
|
||||||
|
"{% url 'api-supplier-part-list' %}",
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
part: {{ part.part.id }},
|
||||||
|
part_detail: true,
|
||||||
|
supplier_detail: true,
|
||||||
|
manufacturer_detail: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
linkButtonsToSelection($("#supplier-table"), ['#supplier-part-options'])
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -55,8 +55,10 @@ price_break_urls = [
|
|||||||
|
|
||||||
manufacturer_part_detail_urls = [
|
manufacturer_part_detail_urls = [
|
||||||
url(r'^edit/?', views.ManufacturerPartEdit.as_view(), name='manufacturer-part-edit'),
|
url(r'^edit/?', views.ManufacturerPartEdit.as_view(), name='manufacturer-part-edit'),
|
||||||
|
|
||||||
|
url(r'^suppliers/', views.ManufacturerPartDetail.as_view(template_name='company/manufacturer_part_suppliers.html'), name='manufacturer-part-suppliers'),
|
||||||
|
|
||||||
url('^.*$', views.ManufacturerPartDetail.as_view(template_name='company/manufacturer_part_detail.html'), name='manufacturer-part-detail'),
|
url('^.*$', views.ManufacturerPartDetail.as_view(template_name='company/manufacturer_part_suppliers.html'), name='manufacturer-part-detail'),
|
||||||
]
|
]
|
||||||
|
|
||||||
manufacturer_part_urls = [
|
manufacturer_part_urls = [
|
||||||
|
Loading…
Reference in New Issue
Block a user