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