Lots
albert.collections.lots
AlbertSession
AlbertSession(
*,
base_url: str,
token: str | None = None,
client_credentials: ClientCredentials | None = None,
retries: int | None = None,
)
Bases: Session
A session that has a base URL, which is prefixed to all request URLs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url
|
str
|
The base URL to prefix to all requests. (e.g., "https://sandbox.albertinvent.com") |
required |
retries
|
int
|
The number of retries for failed requests. Defaults to 3. |
None
|
client_credentials
|
ClientCredentials | None
|
The client credentials for programmatic authentication. Optional if token is provided. |
None
|
token
|
str | None
|
The JWT token for authentication. Optional if client credentials are provided. |
None
|
Methods:
Name | Description |
---|---|
request |
|
Source code in src/albert/session.py
request
Source code in src/albert/session.py
BaseCollection
BaseCollection(*, session: AlbertSession)
BaseCollection is the base class for all collection classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AlbertSession
|
The Albert API Session instance. |
required |
Source code in src/albert/collections/base.py
Lot
Bases: BaseResource
A lot in Albert.
Attributes:
Name | Type | Description |
---|---|---|
id |
LotId | None
|
The Albert ID of the lot. Set when the lot is retrieved from Albert. |
inventory_id |
InventoryId
|
The Albert ID of the inventory item associated with the lot. |
task_id |
str | None
|
The Albert ID of the task associated with the creation of lot. Optional. |
notes |
str | None
|
The notes associated with the lot. Optional. |
expiration_date |
str | None
|
The expiration date of the lot. YYYY-MM-DD format. Optional. |
manufacturer_lot_number |
str | None
|
The manufacturer lot number of the lot. Optional. |
storage_location |
StorageLocation | None
|
The storage location of the lot. Optional. |
pack_size |
str | None
|
The pack size of the lot. Optional. Used to calculate the cost per unit. |
initial_quantity |
NonNegativeFloat | None
|
The initial quantity of the lot. Optional. |
cost |
NonNegativeFloat | None
|
The cost of the lot. Optional. |
inventory_on_hand |
NonNegativeFloat
|
The inventory on hand of the lot. |
owner |
list[User] | None
|
The owners of the lot. Optional. |
lot_number |
str | None
|
The lot number of the lot. Optional. |
external_barcode_id |
str | None
|
The external barcode ID of the lot. Optional. |
metadata |
dict[str, str | list[EntityLink] | EntityLink] | None
|
The metadata of the lot. Optional. Metadata allowed values can be found using the Custom Fields API. |
has_notes |
bool
|
Whether the lot has notes. Read-only. |
has_attachments |
bool
|
Whether the lot has attachments. Read-only. |
barcode_id |
str
|
The barcode ID of the lot. Read-only. |
Methods:
Name | Description |
---|---|
serialize_cost |
|
serialize_initial_quantity |
|
serialize_inventory_on_hand |
|
validate_has_attachments |
|
validate_has_notes |
|
barcode_id
class-attribute
instance-attribute
barcode_id: str | None = Field(
default=None, alias="barcodeId"
)
expiration_date
class-attribute
instance-attribute
expiration_date: str | None = Field(
None, alias="expirationDate"
)
external_barcode_id
class-attribute
instance-attribute
external_barcode_id: str | None = Field(
None, alias="externalBarcodeId"
)
has_attachments
class-attribute
instance-attribute
has_attachments: bool | None = Field(
default=None,
alias="hasAttachments",
exclude=True,
frozen=True,
)
has_notes
class-attribute
instance-attribute
has_notes: bool | None = Field(
default=None,
alias="hasNotes",
exclude=True,
frozen=True,
)
initial_quantity
class-attribute
instance-attribute
inventory_on_hand
class-attribute
instance-attribute
inventory_on_hand: float = Field(alias='inventoryOnHand')
location
class-attribute
instance-attribute
location: SerializeAsEntityLink[Location] | None = Field(
default=None,
alias="Location",
exclude=True,
frozen=True,
)
lot_number
class-attribute
instance-attribute
lot_number: str | None = Field(None, alias='lotNumber')
manufacturer_lot_number
class-attribute
instance-attribute
manufacturer_lot_number: str | None = Field(
None, alias="manufacturerLotNumber"
)
metadata
class-attribute
instance-attribute
notes
class-attribute
instance-attribute
notes: str | None = Field(
default=None, exclude=True, frozen=True
)
owner
class-attribute
instance-attribute
parent_category
class-attribute
instance-attribute
parent_category: InventoryCategory | None = Field(
default=None,
alias="parentCategory",
exclude=True,
frozen=True,
)
parent_name
class-attribute
instance-attribute
parent_name: str | None = Field(
default=None,
alias="parentName",
exclude=True,
frozen=True,
)
parent_unit
class-attribute
instance-attribute
parent_unit: str | None = Field(
default=None,
alias="parentUnit",
exclude=True,
frozen=True,
)
storage_location
class-attribute
instance-attribute
storage_location: (
SerializeAsEntityLink[StorageLocation] | None
) = Field(alias="StorageLocation", default=None)
task_id
class-attribute
instance-attribute
task_id: str | None = Field(default=None, alias='taskId')
serialize_cost
serialize_initial_quantity
serialize_inventory_on_hand
validate_has_attachments
LotCollection
LotCollection(*, session: AlbertSession)
Bases: BaseCollection
LotCollection is a collection class for managing Lot entities in the Albert platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AlbertSession
|
An Albert session instance. |
required |
Methods:
Name | Description |
---|---|
create |
|
delete |
Delete a lot by its ID. |
get_by_id |
Get a lot by its ID. |
get_by_ids |
Get a list of lots by their IDs. |
list |
Lists Lot entities with optional filters. |
update |
Update a lot. |
Source code in src/albert/collections/lots.py
create
Source code in src/albert/collections/lots.py
delete
delete(*, id: str) -> None
Delete a lot by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the lot to delete. |
required |
get_by_id
get_by_ids
Get a list of lots by their IDs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids
|
list[str]
|
A list of lot IDs to get. |
required |
Returns:
Type | Description |
---|---|
list[Lot]
|
A list of lots with the provided IDs. |
Source code in src/albert/collections/lots.py
list
list(
*,
limit: int = 100,
start_key: str | None = None,
parent_id: str | None = None,
inventory_id: str | None = None,
barcode_id: str | None = None,
parent_id_category: str | None = None,
inventory_on_hand: str | None = None,
location_id: str | None = None,
exact_match: bool = False,
begins_with: bool = False,
) -> Iterator[Lot]
Lists Lot entities with optional filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit
|
int
|
The maximum number of Lots to return, by default 100. |
100
|
start_key
|
Optional[str]
|
The primary key of the first item to evaluate for pagination. |
None
|
parent_id
|
Optional[str]
|
Fetches list of lots for a parentId (inventory). |
None
|
inventory_id
|
Optional[str]
|
Fetches list of lots for an inventory. |
None
|
barcode_id
|
Optional[str]
|
Fetches list of lots for a barcodeId. |
None
|
parent_id_category
|
Optional[str]
|
Fetches list of lots for a parentIdCategory (e.g., RawMaterials, Consumables). |
None
|
inventory_on_hand
|
Optional[str]
|
Fetches records based on inventoryOnHand (lteZero, gtZero, eqZero). |
None
|
location_id
|
Optional[str]
|
Fetches list of lots for a locationId. |
None
|
exact_match
|
bool
|
Determines if barcodeId field should be an exact match, by default False. |
False
|
begins_with
|
bool
|
Determines if barcodeId begins with a certain value, by default False. |
False
|
Yields:
Type | Description |
---|---|
Iterator[Lot]
|
An iterator of Lot objects. |
Source code in src/albert/collections/lots.py
update
Update a lot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lot
|
Lot
|
The updated lot object. |
required |
Returns:
Type | Description |
---|---|
Lot
|
The updated lot object as returned by the server. |