Work Locations Service - Nioron07/Easy-Acumatica GitHub Wiki
This guide covers the WorkLocationsService
, which is your primary tool for creating and retrieving work location records through the contract-based API.
[!WARNING] This service is currently untested due to limitations in the development environment. Please contact the library maintainers on GitHub if you encounter any issues with this specific endpoint.
1. Importing Helpers
Before you start, import the necessary builders and query helpers.
from easy_acumatica.models.work_location_builder import WorkLocationBuilder
from easy_acumatica.models.query_builder import QueryOptions
from easy_acumatica.filters import F
2. Understanding the Service's Purpose
The WorkLocationsService
provides methods for creating new work locations and retrieving existing ones. It interacts with the WorkLocation
endpoint.
3. WorkLocationsService Methods
The following table summarizes the primary methods available in the WorkLocationsService
.
Method | Description | Key Parameters |
---|---|---|
.create_work_location() |
Creates a new work location record. | api_version , builder , options |
.get_work_locations() |
Retrieves a list of work locations. | api_version , options |
4. Creating and Retrieving Work Locations
The primary workflow involves creating new work locations or querying for existing ones.
create_work_location(api_version, builder, options)
This method creates a new work location. You must provide a WorkLocationBuilder
instance containing the location's details.
Example: Create a new work location
from easy_acumatica.models.work_location_builder import WorkLocationBuilder
# 1. Build the work location payload
# This assumes a WorkLocationBuilder with methods like location_id and description
location_payload = (
WorkLocationBuilder()
.location_id("WAREHOUSE-B")
.description("Secondary Warehouse Location")
.active(True)
)
# 2. Use the payload to create the record
try:
new_location = client.work_locations.create_work_location("24.200.001", builder=location_payload)
print(f"Successfully created Work Location: {new_location['LocationID']['value']}")
except Exception as e:
print(f"Failed to create work location: {e}")
get_work_locations(api_version, options)
This method retrieves a list of work locations. You can use QueryOptions
to filter for specific locations.
Example: Get all active work locations
# 1. Define query options
query = QueryOptions(filter=F.Active == True)
# 2. Retrieve the work location(s)
try:
locations = client.work_locations.get_work_locations("24.200.001", options=query)
for loc in locations:
print(f"ID: {loc['LocationID']['value']}, Description: {loc['Description']['value']}")
except Exception as e:
print(f"Failed to get work locations: {e}")