mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-16 01:08:12 +00:00
Add parameter support for build orders
This commit is contained in:
@@ -24,7 +24,7 @@ from build.models import Build, BuildItem, BuildLine
|
||||
from build.status_codes import BuildStatus, BuildStatusGroups
|
||||
from data_exporter.mixins import DataExportViewMixin
|
||||
from generic.states.api import StatusView
|
||||
from InvenTree.api import BulkDeleteMixin, MetadataView
|
||||
from InvenTree.api import BulkDeleteMixin, MetadataView, ParameterListMixin
|
||||
from InvenTree.fields import InvenTreeOutputOption, OutputConfiguration
|
||||
from InvenTree.filters import (
|
||||
SEARCH_ORDER_FILTER_ALIAS,
|
||||
@@ -336,13 +336,20 @@ class BuildListOutputOptions(OutputConfiguration):
|
||||
OPTIONS = [InvenTreeOutputOption('part_detail', default=True)]
|
||||
|
||||
|
||||
class BuildList(DataExportViewMixin, BuildMixin, OutputOptionsMixin, ListCreateAPI):
|
||||
class BuildList(
|
||||
DataExportViewMixin,
|
||||
BuildMixin,
|
||||
OutputOptionsMixin,
|
||||
ParameterListMixin,
|
||||
ListCreateAPI,
|
||||
):
|
||||
"""API endpoint for accessing a list of Build objects.
|
||||
|
||||
- GET: Return list of objects (with filters)
|
||||
- POST: Create a new Build object
|
||||
"""
|
||||
|
||||
parameter_model_class = Build
|
||||
output_options = BuildListOutputOptions
|
||||
filterset_class = BuildFilter
|
||||
filter_backends = SEARCH_ORDER_FILTER_ALIAS
|
||||
|
||||
@@ -76,6 +76,7 @@ class BuildReportContext(report.mixins.BaseReportContext):
|
||||
class Build(
|
||||
InvenTree.models.PluginValidationMixin,
|
||||
report.mixins.InvenTreeReportMixin,
|
||||
InvenTree.models.InvenTreeParameterMixin,
|
||||
InvenTree.models.InvenTreeAttachmentMixin,
|
||||
InvenTree.models.InvenTreeBarcodeMixin,
|
||||
InvenTree.models.InvenTreeNotesMixin,
|
||||
@@ -85,7 +86,7 @@ class Build(
|
||||
InvenTree.models.MetadataMixin,
|
||||
InvenTree.models.InvenTreeTree,
|
||||
):
|
||||
"""A Build object organises the creation of new StockItem objects from other existing StockItem objects.
|
||||
"""A Build object organizes the creation of new StockItem objects from other existing StockItem objects.
|
||||
|
||||
Attributes:
|
||||
part: The part to be built (from component BOM items)
|
||||
|
||||
@@ -22,6 +22,7 @@ from rest_framework import serializers
|
||||
from rest_framework.serializers import ValidationError
|
||||
|
||||
import build.tasks
|
||||
import common.serializers
|
||||
import common.settings
|
||||
import company.serializers
|
||||
import InvenTree.helpers
|
||||
@@ -101,6 +102,7 @@ class BuildSerializer(
|
||||
'issued_by_detail',
|
||||
'responsible',
|
||||
'responsible_detail',
|
||||
'parameters',
|
||||
'priority',
|
||||
'level',
|
||||
]
|
||||
@@ -124,6 +126,12 @@ class BuildSerializer(
|
||||
True,
|
||||
)
|
||||
|
||||
parameters = enable_filter(
|
||||
common.serializers.ParameterSerializer(many=True, read_only=True),
|
||||
False,
|
||||
filter_name='parameters',
|
||||
)
|
||||
|
||||
part_name = serializers.CharField(
|
||||
source='part.name', read_only=True, label=_('Part Name')
|
||||
)
|
||||
|
||||
@@ -45,6 +45,7 @@ import AttachmentPanel from '../../components/panels/AttachmentPanel';
|
||||
import NotesPanel from '../../components/panels/NotesPanel';
|
||||
import type { PanelType } from '../../components/panels/Panel';
|
||||
import { PanelGroup } from '../../components/panels/PanelGroup';
|
||||
import ParametersPanel from '../../components/panels/ParametersPanel';
|
||||
import { StatusRenderer } from '../../components/render/StatusRenderer';
|
||||
import { RenderStockLocation } from '../../components/render/Stock';
|
||||
import { useBuildOrderFields } from '../../forms/BuildForms';
|
||||
@@ -519,6 +520,10 @@ export default function BuildDetail() {
|
||||
<Skeleton />
|
||||
)
|
||||
},
|
||||
ParametersPanel({
|
||||
model_type: ModelType.build,
|
||||
model_id: build.pk
|
||||
}),
|
||||
AttachmentPanel({
|
||||
model_type: ModelType.build,
|
||||
model_id: build.pk
|
||||
|
||||
Reference in New Issue
Block a user