Skip to content

Commit 100a579

Browse files
author
Jens Kürten
committed
feat: Add BOMItemFieldCalculationEvent and related data model
1 parent 6d9c748 commit 100a579

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

csfunctions/events/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pydantic import Field
44

5+
from .bom_item_field_calculation import BOMItemFieldCalculationData, BOMItemFieldCalculationEvent
56
from .custom_operations import (
67
CustomOperationDocumentData,
78
CustomOperationDocumentEvent,
@@ -37,6 +38,7 @@
3738
| PartReleasedEvent
3839
| PartReleaseCheckEvent
3940
| PartFieldCalculationEvent
41+
| BOMItemFieldCalculationEvent
4042
| FieldValueCalculationEvent
4143
| DummyEvent
4244
| EngineeringChangeReleasedEvent
@@ -59,6 +61,7 @@
5961
| PartReleasedData
6062
| PartReleaseCheckData
6163
| PartFieldCalculationData
64+
| BOMItemFieldCalculationData
6265
| FieldValueCalculationData
6366
| DummyEventData
6467
| EngineeringChangeReleasedData
@@ -81,6 +84,7 @@
8184
"PartReleasedEvent",
8285
"PartReleaseCheckEvent",
8386
"PartFieldCalculationEvent",
87+
"BOMItemFieldCalculationEvent",
8488
"FieldValueCalculationEvent",
8589
"DummyEvent",
8690
"EngineeringChangeReleasedEvent",
@@ -91,6 +95,7 @@
9195
"DocumentFieldCalculationData",
9296
"PartReleasedData",
9397
"PartReleaseCheckData",
98+
"BOMItemFieldCalculationData",
9499
"FieldValueCalculationData",
95100
"DummyEventData",
96101
"EngineeringChangeReleasedData",

csfunctions/events/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class EventNames(str, Enum):
1111
PART_RELEASED = "part_released"
1212
PART_RELEASE_CHECK = "part_release_check"
1313
PART_FIELD_CALCULATION = "part_field_calculation"
14+
BOM_ITEM_FIELD_CALCULATION = "bom_item_field_calculation"
1415
ENGINEERING_CHANGE_RELEASED = "engineering_change_released"
1516
ENGINEERING_CHANGE_RELEASE_CHECK = "engineering_change_release_check"
1617
FIELD_VALUE_CALCULATION = "field_value_calculation"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import Literal
2+
3+
from pydantic import BaseModel, Field
4+
5+
from csfunctions.objects import BOMItem, Part
6+
7+
from .base import BaseEvent, EventNames
8+
9+
10+
class BOMItemFieldCalculationData(BaseModel):
11+
bom_item: BOMItem = Field(..., description="Current state of the BOM item")
12+
action: Literal["create", "modify", "copy", "index"] = Field(..., description="Action being performed")
13+
part: Part = Field(..., description="Part of the BOM item")
14+
15+
16+
class BOMItemFieldCalculationEvent(BaseEvent):
17+
name: Literal[EventNames.BOM_ITEM_FIELD_CALCULATION] = EventNames.BOM_ITEM_FIELD_CALCULATION
18+
data: BOMItemFieldCalculationData

docs/reference/events.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,24 @@ The event expects a DataResponse containing a dictionary of field names and thei
265265
| documents | list[[Document](objects.md#document)] | List of documents that belong to the part |
266266

267267

268+
## BOMItemFieldCalculationEvent
269+
`csfunctions.events.BOMItemFieldCalculationEvent`
270+
271+
This event is fired when a BOM item is created, modified, copied or indexed. It is triggered after the field calculations defined in the datasheet editor are performed.
272+
273+
The event expects a DataResponse containing a dictionary of field names and their new values. Fields that are not mentioned in the response are not updated.
274+
275+
**BOMItemFieldCalculationEvent.name:** bom_item_field_calculation
276+
277+
**BOMItemFieldCalculationEvent.data:**
278+
279+
| Attribute | Type | Description |
280+
| --------- | -------------------------------------------- | ----------------------------- |
281+
| bom_item | [BOMItem](objects.md#bomitem) | Current state of the BOM item |
282+
| action | Literal["create", "modify", "copy", "index"] | Action being performed |
283+
| part | [Part](objects.md#part) | Part of the BOM item |
284+
285+
268286
## WorkflowTaskTriggerEvent
269287
`csfunctions.events.WorkflowTaskTriggerEvent`
270288

0 commit comments

Comments
 (0)