mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Make 'part_detail' field in SupplierPart serializer optional
This commit is contained in:
parent
cf5b8d0249
commit
9052ccc181
@ -11,6 +11,8 @@ from rest_framework import generics, permissions
|
||||
|
||||
from django.conf.urls import url, include
|
||||
|
||||
from InvenTree.helpers import str2bool
|
||||
|
||||
from .models import Company
|
||||
from .models import SupplierPart, SupplierPriceBreak
|
||||
|
||||
@ -84,6 +86,16 @@ class SupplierPartList(generics.ListCreateAPIView):
|
||||
'supplier',
|
||||
'pricebreaks')
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
|
||||
# Do we wish to include extra detail?
|
||||
part_detail = str2bool(self.request.GET.get('part_detail', None))
|
||||
|
||||
kwargs['part_detail'] = part_detail
|
||||
kwargs['context'] = self.get_serializer_context()
|
||||
|
||||
return self.serializer_class(*args, **kwargs)
|
||||
|
||||
serializer_class = SupplierPartSerializer
|
||||
|
||||
permission_classes = [
|
||||
|
@ -64,6 +64,15 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
||||
|
||||
pricing = serializers.CharField(source='unit_pricing', read_only=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
part_detail = kwargs.pop('part_detail', False)
|
||||
|
||||
super(SupplierPartSerializer, self).__init__(*args, **kwargs)
|
||||
|
||||
if part_detail is not True:
|
||||
self.fields.pop('part_detail')
|
||||
|
||||
class Meta:
|
||||
model = SupplierPart
|
||||
fields = [
|
||||
|
@ -47,10 +47,13 @@
|
||||
$("#part-table").bootstrapTable({
|
||||
sortable: true,
|
||||
search: true,
|
||||
pagination: true,
|
||||
pageSize: 50,
|
||||
formatNoMatches: function() { return "No supplier parts found for {{ company.name }}"; },
|
||||
queryParams: function(p) {
|
||||
return {
|
||||
supplier: {{ company.id }}
|
||||
supplier: {{ company.id }},
|
||||
part_detail: true,
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
|
@ -45,6 +45,7 @@ InvenTree | Supplier List
|
||||
sortable: true,
|
||||
search: true,
|
||||
pagination: true,
|
||||
pageSize: 50,
|
||||
formatNoMatches: function() { return "No company information found"; },
|
||||
columns: [
|
||||
{
|
||||
|
@ -35,6 +35,7 @@
|
||||
sortable: true,
|
||||
search: true,
|
||||
pagination: true,
|
||||
pageSize: 50,
|
||||
queryParams: function(p) {
|
||||
return {
|
||||
part: {{ part.id }},
|
||||
|
@ -377,7 +377,7 @@ function loadStockTable(table, options) {
|
||||
search: true,
|
||||
method: 'get',
|
||||
pagination: true,
|
||||
pageSize: 25,
|
||||
pageSize: 50,
|
||||
rememberOrder: true,
|
||||
queryParams: options.params,
|
||||
columns: [
|
||||
@ -558,6 +558,7 @@ function loadStockTrackingTable(table, options) {
|
||||
queryParams: options.params,
|
||||
columns: cols,
|
||||
pagination: true,
|
||||
pageSize: 50,
|
||||
url: options.url,
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user