Órdenes de compra¶
Recurso client.purchase_orders (endpoint purchase-orders). Agrega envío por correo, anular y comentarios a las operaciones de Actions.
alegrapy.purchase_orders.PurchaseOrders
¶
Bases: Actions
Operations related to purchase orders (órdenes de compra) endpoint.
__init__(client=None)
¶
Initialize the resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AlegraClient
|
The AlegraClient instance. |
None
|
send_email(id, emails, send_copy_to_user=False, subject=None, message=None)
¶
Send purchase order by email.
.. note:: This endpoint is not documented by Alegra; its existence was verified on 2026-11-21. It may change without notice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int or str
|
Purchase order ID. |
required |
emails
|
list or str
|
Email address or list of email addresses to send to. |
required |
send_copy_to_user
|
bool
|
Send a copy of the email to the user (default False). |
False
|
subject
|
str
|
Custom email subject. |
None
|
message
|
str
|
Custom email body message. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Parsed JSON response from the server. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the ID is not a valid resource identifier. |
void(id)
¶
Void / Annul a purchase order by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int or str
|
Purchase order ID. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Parsed JSON response from the server. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the ID is not a valid resource identifier. |
add_comment(id, comment_text)
¶
Add comments to a purchase order.
.. note::
This endpoint is not documented by Alegra; its existence was verified on
2026-11-21. It may change without notice.
Alegra was observed answering a missing purchase order with HTTP 200 and
an error body ({"code": 37009, ...}); that case is raised as an error
(see Raises). Its status_code is None because the 2xx status is
not exposed by the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int or str
|
Purchase order ID. |
required |
comment_text
|
str
|
The text comment to add. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Parsed JSON response from the server. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the ID is not a valid resource identifier. |
AlegraNotFoundError
|
If Alegra answers 2xx with an error body whose code is 37009 (the purchase order does not exist). |
AlegraAPIError
|
If Alegra answers 2xx with any other error body. |