Skip to content

Commit

Permalink
Merge branch 'pui-reports' of github.com:SchrodingersGat/InvenTree in…
Browse files Browse the repository at this point in the history
…to pui-reports
  • Loading branch information
SchrodingersGat committed May 13, 2024
2 parents e8b803a + 9349781 commit afc66d4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
28 changes: 13 additions & 15 deletions src/backend/InvenTree/report/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.core.exceptions import ValidationError
from django.core.files.base import ContentFile
from django.http import HttpResponse
from django.template.exceptions import TemplateDoesNotExist
from django.urls import include, path
from django.utils.decorators import method_decorator
Expand All @@ -11,8 +10,7 @@

from django_filters import rest_framework as rest_filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import permissions, serializers
from rest_framework.exceptions import NotFound
from rest_framework import permissions
from rest_framework.generics import GenericAPIView
from rest_framework.request import clone_request
from rest_framework.response import Response
Expand All @@ -23,7 +21,7 @@
import report.helpers
import report.models
import report.serializers
from InvenTree.api import MetadataView
from InvenTree.api import BulkDeleteMixin, MetadataView
from InvenTree.exceptions import log_error
from InvenTree.filters import InvenTreeSearchFilter
from InvenTree.mixins import (
Expand Down Expand Up @@ -472,18 +470,18 @@ class ReportAssetDetail(RetrieveUpdateDestroyAPI):
serializer_class = report.serializers.ReportAssetSerializer


class LabelOutputList(ListAPI):
class LabelOutputList(BulkDeleteMixin, ListAPI):
"""List endpoint for LabelOutput objects."""

queryset = report.models.LabelOutput.objects.all()
serializer_class = report.serializers.LabelOutputSerializer


class LabelOutputDetail(RetrieveAPI):
"""Detail endpoint for a single LabelOutput object."""
class ReportOutputList(BulkDeleteMixin, ListAPI):
"""List endpoint for ReportOutput objects."""

queryset = report.models.LabelOutput.objects.all()
serializer_class = report.serializers.LabelOutputSerializer
queryset = report.models.ReportOutput.objects.all()
serializer_class = report.serializers.ReportOutputSerializer


label_api_urls = [
Expand Down Expand Up @@ -515,12 +513,7 @@ class LabelOutputDetail(RetrieveAPI):
# Label outputs
path(
'output/',
include([
path(
'<int:pk>/', LabelOutputDetail.as_view(), name='api-label-output-detail'
),
path('', LabelOutputList.as_view(), name='api-label-output-list'),
]),
include([path('', LabelOutputList.as_view(), name='api-label-output-list')]),
),
]

Expand Down Expand Up @@ -550,6 +543,11 @@ class LabelOutputDetail(RetrieveAPI):
path('', ReportTemplateList.as_view(), name='api-report-template-list'),
]),
),
# Generated report outputs
path(
'output/',
include([path('', ReportOutputList.as_view(), name='api-report-output-list')]),
),
# Report assets
path(
'asset/',
Expand Down
4 changes: 4 additions & 0 deletions src/backend/InvenTree/report/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from InvenTree.serializers import (
InvenTreeAttachmentSerializerField,
InvenTreeModelSerializer,
UserSerializer,
)


Expand Down Expand Up @@ -152,6 +153,7 @@ def base_fields():
'pk',
'created',
'user',
'user_detail',
'model_type',
'items',
'complete',
Expand All @@ -163,6 +165,8 @@ def base_fields():
output = InvenTreeAttachmentSerializerField()
model_type = serializers.CharField(source='template.model_type', read_only=True)

user_detail = UserSerializer(source='user', read_only=True, many=False)


class LabelOutputSerializer(BaseOutputSerializer):
"""Serializer class for the LabelOutput model."""
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/enums/ApiEndpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ export enum ApiEndpoints {
// Template API endpoints
label_list = 'label/template/',
label_print = 'label/print/',
label_output = 'label/output/',
report_list = 'report/template/',
report_print = 'report/print/',
report_output = 'report/output/',
report_snippet = 'report/snippet/',
report_asset = 'report/asset/',

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/tables/ColumnRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ export function CurrencyColumn({
sortable: sortable ?? true,
render: (record: any) => {
let currency_key = currency_accessor ?? `${accessor}_currency`;
return formatCurrency(record[accessor], {
currency: currency ?? record[currency_key]
return formatCurrency(resolveItem(record, accessor), {
currency: currency ?? resolveItem(record, currency_key)
});
}
};
Expand Down

0 comments on commit afc66d4

Please sign in to comment.