mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 21:16:46 +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 django.conf.urls import url, include
|
||||||
|
|
||||||
|
from InvenTree.helpers import str2bool
|
||||||
|
|
||||||
from .models import Company
|
from .models import Company
|
||||||
from .models import SupplierPart, SupplierPriceBreak
|
from .models import SupplierPart, SupplierPriceBreak
|
||||||
|
|
||||||
@ -84,6 +86,16 @@ class SupplierPartList(generics.ListCreateAPIView):
|
|||||||
'supplier',
|
'supplier',
|
||||||
'pricebreaks')
|
'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
|
serializer_class = SupplierPartSerializer
|
||||||
|
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
|
@ -64,6 +64,15 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
pricing = serializers.CharField(source='unit_pricing', read_only=True)
|
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:
|
class Meta:
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
fields = [
|
fields = [
|
||||||
|
@ -47,10 +47,13 @@
|
|||||||
$("#part-table").bootstrapTable({
|
$("#part-table").bootstrapTable({
|
||||||
sortable: true,
|
sortable: true,
|
||||||
search: true,
|
search: true,
|
||||||
|
pagination: true,
|
||||||
|
pageSize: 50,
|
||||||
formatNoMatches: function() { return "No supplier parts found for {{ company.name }}"; },
|
formatNoMatches: function() { return "No supplier parts found for {{ company.name }}"; },
|
||||||
queryParams: function(p) {
|
queryParams: function(p) {
|
||||||
return {
|
return {
|
||||||
supplier: {{ company.id }}
|
supplier: {{ company.id }},
|
||||||
|
part_detail: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
|
@ -45,6 +45,7 @@ InvenTree | Supplier List
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
search: true,
|
search: true,
|
||||||
pagination: true,
|
pagination: true,
|
||||||
|
pageSize: 50,
|
||||||
formatNoMatches: function() { return "No company information found"; },
|
formatNoMatches: function() { return "No company information found"; },
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
search: true,
|
search: true,
|
||||||
pagination: true,
|
pagination: true,
|
||||||
|
pageSize: 50,
|
||||||
queryParams: function(p) {
|
queryParams: function(p) {
|
||||||
return {
|
return {
|
||||||
part: {{ part.id }},
|
part: {{ part.id }},
|
||||||
|
@ -377,7 +377,7 @@ function loadStockTable(table, options) {
|
|||||||
search: true,
|
search: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
pagination: true,
|
pagination: true,
|
||||||
pageSize: 25,
|
pageSize: 50,
|
||||||
rememberOrder: true,
|
rememberOrder: true,
|
||||||
queryParams: options.params,
|
queryParams: options.params,
|
||||||
columns: [
|
columns: [
|
||||||
@ -558,6 +558,7 @@ function loadStockTrackingTable(table, options) {
|
|||||||
queryParams: options.params,
|
queryParams: options.params,
|
||||||
columns: cols,
|
columns: cols,
|
||||||
pagination: true,
|
pagination: true,
|
||||||
|
pageSize: 50,
|
||||||
url: options.url,
|
url: options.url,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user