StockItemBuilder
The `StockItemBuilder` is your primary tool for creating the JSON payload needed to create or update `StockItem` records with the `StockItemsService`.
Importing the Builder
To get started, import the `StockItemBuilder` from the `easy_acumatica.models` module.
from easy_acumatica.models.stock_item_builder import StockItemBuilder
Builder Methods
Standard Fields
Use the shortcut methods to set common header-level fields on the stock item. For any other field, you can use the generic `.set()` method.
item_payload = (
StockItemBuilder()
.inventory_id("WIDGET-01")
.description("Standard Widget")
.item_class("STD")
.note("Internal note about sourcing.")
.set("ItemStatus", "Active")
)
.add_attribute(attribute_id, value)
Adds an attribute line to the item. You can chain this method to add multiple attributes.
item_payload = (
StockItemBuilder()
.inventory_id("NEW-ITEM-003")
.add_attribute(attribute_id="COLOR", value="Green")
.add_attribute(attribute_id="SIZE", value="Medium")
)
# Use with StockItemsService to create the record
# client.stock_items.create_stock_item("24.200.001", builder=item_payload)
.to_body()
Once you have set all the required fields, call `.to_body()` to generate the final dictionary, which is ready to be sent as the JSON body in your API request.
ON THIS PAGE
Introduction
Importing Builder
Builder Methods
- Standard Fields
- .add_attribute()
- .to_body()