Auth¶
Authentication utilities and sudo operations for posting messages as other users.
auth
¶
Authentication utilities for Vodoo.
get_default_user_id
¶
get_default_user_id(client: OdooClient, username: str | None = None) -> int
Get the default user ID for sudo operations.
| PARAMETER | DESCRIPTION |
|---|---|
client
|
Odoo client
TYPE:
|
username
|
Username to search for (defaults to configured username)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
User ID |
| RAISES | DESCRIPTION |
|---|---|
RecordNotFoundError
|
If user not found |
Source code in src/vodoo/auth.py
get_partner_id_from_user
¶
get_partner_id_from_user(client: OdooClient, user_id: int) -> int
Get the partner ID associated with a user.
In Odoo, res.users has a partner_id field that links to res.partner. The mail.message.author_id field references res.partner, not res.users.
| PARAMETER | DESCRIPTION |
|---|---|
client
|
Odoo client
TYPE:
|
user_id
|
User ID (res.users)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Partner ID (res.partner) |
| RAISES | DESCRIPTION |
|---|---|
RecordNotFoundError
|
If user not found or has no partner |
Source code in src/vodoo/auth.py
message_post_sudo
¶
message_post_sudo(client: OdooClient, model: str, res_id: int, body: str, user_id: int | None = None, message_type: str = 'comment', is_note: bool = False, **kwargs: Any) -> bool
Post a message or note as a specific user using sudo.
| PARAMETER | DESCRIPTION |
|---|---|
client
|
Odoo client
TYPE:
|
model
|
Model name (e.g., 'helpdesk.ticket')
TYPE:
|
res_id
|
Record ID
TYPE:
|
body
|
Message body (HTML)
TYPE:
|
user_id
|
User ID to post as (uses default if None)
TYPE:
|
message_type
|
Type of message ('comment' or 'notification')
TYPE:
|
is_note
|
If True, creates an internal note (not visible to customers)
TYPE:
|
**kwargs
|
Additional arguments for message_post
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if successful |
| RAISES | DESCRIPTION |
|---|---|
ConfigurationError
|
If no default user configured |