Generic CRUD¶
GenericNamespace for generic model operations that work with any Odoo model, accessed as client.generic.
update(..., check_write_date=expected) offers a best-effort, non-atomic
freshness preflight, not compare-and-set. Changes after the read or within the
same second can be missed. See freshness checks and errors.
generic
¶
Generic Odoo model operations.
GenericNamespace
¶
GenericNamespace(client: OdooClient)
Generic model operations for any Odoo model.
Source code in src/vodoo/generic.py
create
¶
Create a new record.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model name (e.g., 'product.template')
TYPE:
|
values
|
Dictionary of field values
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
ID of created record |
Examples:
Source code in src/vodoo/generic.py
update
¶
update(model: str, record_id: int, values: dict[str, Any], *, check_write_date: str | None = None) -> bool
Update a record.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model name
TYPE:
|
record_id
|
Record ID
TYPE:
|
values
|
Dictionary of field values to update
TYPE:
|
check_write_date
|
Optional best-effort, non-atomic UTC seconds freshness check. Changes after the read or within the same second can be missed; this is not compare-and-set.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if successful |
Examples:
Source code in src/vodoo/generic.py
delete
¶
Delete a record.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model name
TYPE:
|
record_id
|
Record ID
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if successful |
Examples:
Source code in src/vodoo/generic.py
search
¶
search(model: str, domain: list[Any] | None = None, fields: list[str] | None = None, limit: int | None = None, offset: int = 0, order: str | None = None) -> list[dict[str, Any]]
Search and read records.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model name
TYPE:
|
domain
|
Search domain
TYPE:
|
fields
|
Fields to fetch
TYPE:
|
limit
|
Maximum number of records
TYPE:
|
offset
|
Number of records to skip
TYPE:
|
order
|
Sort order
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]]
|
List of record dictionaries |
Examples:
Source code in src/vodoo/generic.py
call
¶
call(model: str, method: str, args: list[Any] | None = None, kwargs: dict[str, Any] | None = None) -> Any
Call a custom method on a model.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model name
TYPE:
|
method
|
Method name
TYPE:
|
args
|
Positional arguments
TYPE:
|
kwargs
|
Keyword arguments
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
Method result |
Examples:
>>> ns.call('res.partner', 'name_search', kwargs={'name': 'Acme'})
[(1, 'Acme Corp'), (2, 'Acme Ltd')]
JSON-2 requires method parameters other than record IDs to be passed as named keyword arguments.