Lots
albert.collections.lots.LotCollection
Bases: BaseCollection
Manage Lots in the Albert platform.
A Lot is a specific physical batch or quantity of an Inventory Item, for
example a received shipment or a produced amount. Each lot tracks
lot-specific details such as how much is currently on hand, where it is
stored, its cost, and who owns it. Every lot belongs to exactly one
Inventory Item (its parent), referenced by the parent Inventory ID
(format INV...); a lot's own ID has the format LOT....
Lots are referenced throughout property data: a lot_id scopes results to
a specific physical batch. Some lots are produced by a Task and carry a
task_id linking them back to that Task.
Inventory Items themselves are managed through the Inventory collection
(InventoryCollection).
This collection is accessed as client.lots.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base API route for lot requests. |
Methods:
| Name | Description |
|---|---|
create |
Create one or more new lots. |
get_by_id |
Get a single lot by its ID. |
get_by_ids |
Get many lots by their IDs. |
search |
Fast, lightweight search returning partial lots (best for lookups/counts). |
get_all |
Return fully populated lots matching the given filters. |
adjust |
Adjust a lot's inventory on hand (add, subtract, set, or zero). |
transfer |
Move some or all of a lot's quantity to another storage location. |
update |
Update an existing lot. |
delete |
Delete a lot by its ID. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/lots.py
create
Create one or more new lots.
Use this to register physical batches against an existing Inventory Item
(each lot's inventory_id must point at its parent item). Both regular
lots and Task-produced lots can be created here.
Example
from albert import Albert
from albert.core.shared.models.base import EntityLink
from albert.resources.lots import Lot
client = Albert()
new_lot = Lot(
inventory_id="INVA9999999",
storage_location=EntityLink(id="STL9999999"),
initial_quantity=10.0,
inventory_on_hand=10.0,
cost=50.0,
manufacturer_lot_number="MLN-001",
)
created = client.lots.create(lots=[new_lot])
created[0].id
# 'LOTA1'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lots
|
list[Lot]
|
The lots to create. Each lot requires |
required |
Returns:
| Type | Description |
|---|---|
list[Lot]
|
The created lots, each populated with its assigned Lot ID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a regular lot is missing |
Notes
The SDK validates storage_location, initial_quantity, and
location (task lots) before POST. cost and
manufacturer_lot_number are enforced by the API for RawMaterials
parents but are not yet checked in the SDK. See field docstrings on
Lot for the full create matrix.
If the API reports a partial success (some lots failed to create), a warning is logged and only the successfully created lots are returned.
Source code in src/albert/collections/lots.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
get_by_id
Get a single, fully populated lot by its ID.
To retrieve many lots at once, use get_by_ids. To find lots
without knowing their IDs, use search or get_all.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
LotId
|
The Lot ID to retrieve (format |
required |
Returns:
| Type | Description |
|---|---|
Lot
|
The fully populated lot. |
Source code in src/albert/collections/lots.py
get_by_ids
Get many fully populated lots by their IDs.
Use this instead of repeated get_by_id calls when you already
have several Lot IDs to fetch.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[LotId]
|
The Lot IDs to retrieve (format |
required |
Returns:
| Type | Description |
|---|---|
list[Lot]
|
The lots matching the provided IDs. |
Source code in src/albert/collections/lots.py
delete
delete(*, id: LotId) -> None
Delete a lot by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
LotId
|
The Lot ID to delete (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/lots.py
search
search(
*,
text: str | None = None,
inventory_id: InventoryId
| list[InventoryId]
| None = None,
location_id: str | list[str] | None = None,
storage_location_id: str | list[str] | None = None,
task_id: TaskId | list[TaskId] | None = None,
category: InventoryCategory
| str
| list[InventoryCategory | str]
| None = None,
external_barcode_id: str | list[str] | None = None,
search_field: str | list[str] | None = None,
source_field: str | list[str] | None = None,
additional_field: str | list[str] | None = None,
contains_field: list[str] | None = None,
contains_text: list[str] | None = None,
created_by: list[str] | None = None,
custom_fields: dict[str, Any] | None = None,
facet_field: str | None = None,
facet_text: str | None = None,
inventory: list[str] | None = None,
location: list[str] | None = None,
storage_location: list[str] | None = None,
metadata_filters: dict[str, Any] | None = None,
owner: list[str] | None = None,
status: list[str] | None = None,
to_expiration_date: str | None = None,
is_drop_down: bool | None = None,
order_by: OrderBy = DESCENDING,
sort_by: str | None = None,
offset: int | None = None,
max_items: int | None = None,
) -> Iterator[LotSearchItem]
Search for lots matching the given filters.
This is the fast way to look up lots or count matches. It returns partial
(unhydrated) lots (LotSearchItem) rather
than full ones, so it is well suited to lookups. When you need every field
of each lot, use get_all instead, or hydrate individual results.
All filters are optional and combined together (AND). With no filters, all lots are returned.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text query matched against lot fields. Truncated to 50 characters. |
None
|
inventory_id
|
InventoryId or list[InventoryId]
|
Filter by parent Inventory ID(s) (format |
None
|
location_id
|
str or list[str]
|
Filter by location ID(s). |
None
|
storage_location_id
|
str or list[str]
|
Filter by storage location ID(s) (format |
None
|
task_id
|
TaskId or list[TaskId]
|
Filter by the source Task ID(s) that produced the lots. |
None
|
category
|
InventoryCategory or list[str]
|
Filter by the parent inventory category (e.g. |
None
|
external_barcode_id
|
str or list[str]
|
Filter by external barcode ID(s). |
None
|
search_field
|
str or list[str]
|
Restrict which fields the |
None
|
source_field
|
str or list[str]
|
Restrict which fields are returned in the response. |
None
|
additional_field
|
str or list[str]
|
Request additional columns from the search index. |
None
|
contains_field
|
list[str]
|
Fields to search inside. |
None
|
contains_text
|
list[str]
|
Values to search for within |
None
|
created_by
|
list[str]
|
Filter by creator display name(s) or UserId(s). |
None
|
custom_fields
|
dict[str, Any]
|
Filter by custom field values. |
None
|
facet_field
|
str
|
Facet field to filter on. |
None
|
facet_text
|
str
|
Facet text to search for. |
None
|
inventory
|
list[str]
|
Filter by parent inventory name(s). |
None
|
location
|
list[str]
|
Filter by location name(s). |
None
|
storage_location
|
list[str]
|
Filter by storage location name(s). |
None
|
metadata_filters
|
dict[str, Any]
|
Filter by custom field (metadata) values. |
None
|
owner
|
list[str]
|
Filter by lot owner display name(s) or UserId(s). |
None
|
status
|
list[str]
|
Filter by lot status values. |
None
|
to_expiration_date
|
str
|
Only include lots expiring on or before this date (ISO 8601). |
None
|
is_drop_down
|
bool
|
Apply dropdown sanitization to the search text when True. |
None
|
order_by
|
OrderBy
|
Sort direction for the results. Defaults to |
DESCENDING
|
sort_by
|
str
|
Attribute to sort by. |
None
|
max_items
|
int
|
Maximum number of lots to return in total. If None, returns all matching lots. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[LotSearchItem]
|
An iterator over matching partial (unhydrated) lots. |
Source code in src/albert/collections/lots.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
get_all
get_all(
*,
parent_id: InventoryId | None = None,
inventory_id: InventoryId | None = None,
barcode_id: str | None = None,
parent_id_category: str | None = None,
inventory_on_hand: InventoryOnHandFilter | None = None,
location_id: str | None = None,
exact_match: bool = False,
begins_with: bool = False,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[Lot]
Get fully populated lots matching the given filters.
Same purpose as search, but returns fully populated
Lot objects (every field populated), which
is slower. Use search when a lightweight result is enough.
All filters are optional and combined together (AND). A common use is
passing parent_id to list every lot of one Inventory Item.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
InventoryId
|
Fetch lots whose parent is this Inventory ID (format |
None
|
inventory_id
|
InventoryId
|
Fetch lots for the given inventory ID. |
None
|
barcode_id
|
str
|
Fetch lots with the given barcode ID. |
None
|
parent_id_category
|
str
|
Filter by the parent inventory category (e.g. |
None
|
inventory_on_hand
|
InventoryOnHandFilter
|
Filter by inventory on hand relative to zero. Requires |
None
|
location_id
|
str
|
Filter by location ID. |
None
|
exact_match
|
bool
|
Match |
False
|
begins_with
|
bool
|
Match |
False
|
start_key
|
str
|
Pagination key to continue listing from. |
None
|
max_items
|
int
|
Maximum number of lots to return in total. If None, returns all matching lots. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Lot]
|
An iterator over the fully populated lots matching the filters. |
Source code in src/albert/collections/lots.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |
adjust
adjust(
*,
lot_id: LotId,
action: LotAdjustmentAction,
quantity: float | None = None,
description: str | None = None,
) -> Lot
Adjust a lot's inventory on hand.
Use this to change how much of a lot is currently in stock, for example
to record consumption, restocking, or a physical recount. To move
quantity to a different storage location instead, use transfer.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lot_id
|
LotId
|
The lot to adjust (format |
required |
action
|
LotAdjustmentAction
|
How to apply
|
required |
quantity
|
float
|
The amount to apply. Required and must be greater than zero for
|
None
|
description
|
str
|
Free-text note recorded with the adjustment. |
None
|
Returns:
| Type | Description |
|---|---|
Lot
|
The refreshed lot after the adjustment. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/albert/collections/lots.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 | |
transfer
transfer(
*,
lot_id: LotId,
quantity: float | Literal["ALL"],
storage_location_id: StorageLocationId,
owner: UserId | None = None,
) -> Lot
Transfer some or all of a lot's quantity to another storage location.
Use this to physically relocate stock. Transferring "ALL" simply
moves the source lot to the new storage location. Transferring a partial
amount splits the source lot: the requested quantity is removed from the
source and a new lot is created at the destination.
To change how much is in stock (rather than where it is), use
adjust.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lot_id
|
LotId
|
The source lot to transfer from (format |
required |
quantity
|
float or Literal['ALL']
|
The amount to transfer, or |
required |
storage_location_id
|
StorageLocationId
|
Destination storage location ID (format |
required |
owner
|
UserId
|
User ID (format |
None
|
Returns:
| Type | Description |
|---|---|
Lot
|
The updated source lot for an |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a numeric |
Source code in src/albert/collections/lots.py
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 | |
update
Update an existing lot.
Fetch the lot (e.g. with get_by_id), modify the updatable fields
on the returned object, then pass it here. Only the fields listed in Notes
are applied. The lot is matched by its id.
For quantity changes, prefer adjust; for relocations, prefer
transfer. Both handle the inventory-on-hand bookkeeping for you.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lot
|
Lot
|
The lot carrying the desired changes. Its |
required |
Returns:
| Type | Description |
|---|---|
Lot
|
The refreshed lot after the update. |
Notes
The following fields can be updated: barcode_id, cost,
expiration_date, initial_quantity, inventory_on_hand,
manufacturer_lot_number, metadata, owner, pack_size,
status, storage_location, workflow_id.