Skip to content

Knowledge

KnowledgeNamespace for the knowledge.article model (Odoo Enterprise), accessed as client.knowledge.

knowledge

Knowledge article operations for Vodoo.

KnowledgeNamespace

KnowledgeNamespace(client: OdooClient)

Bases: _KnowledgeAttrs, DomainNamespace

Namespace for knowledge.article model.

Source code in src/vodoo/_domain.py
def __init__(self, client: OdooClient) -> None:
    self._client = client

create

create(name: str, *, body: str | None = None, parent_id: int | None = None, category: str | None = None, icon: str | None = None, **extra_fields: Any) -> int

Create a knowledge article.

PARAMETER DESCRIPTION
name

Article title/name.

TYPE: str

body

Article body as markdown text (converted to HTML).

TYPE: str | None DEFAULT: None

parent_id

Parent article ID.

TYPE: int | None DEFAULT: None

category

Article category (workspace/private/shared).

TYPE: str | None DEFAULT: None

icon

Emoji/icon for the article.

TYPE: str | None DEFAULT: None

**extra_fields

Additional fields to set on the article.

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
int

ID of created article.

Source code in src/vodoo/knowledge.py
def create(
    self,
    name: str,
    *,
    body: str | None = None,
    parent_id: int | None = None,
    category: str | None = None,
    icon: str | None = None,
    **extra_fields: Any,
) -> int:
    """Create a knowledge article.

    Args:
        name: Article title/name.
        body: Article body as markdown text (converted to HTML).
        parent_id: Parent article ID.
        category: Article category (workspace/private/shared).
        icon: Emoji/icon for the article.
        **extra_fields: Additional fields to set on the article.

    Returns:
        ID of created article.
    """
    values = _build_article_values(
        name,
        body=body,
        parent_id=parent_id,
        category=category,
        icon=icon,
        **extra_fields,
    )
    return self._client.create(self._model, values)

url

url(record_id: int) -> str

Get the web URL for a knowledge article.

Tries the article_url field first, falls back to the standard URL.

Source code in src/vodoo/knowledge.py
def url(self, record_id: int) -> str:
    """Get the web URL for a knowledge article.

    Tries the ``article_url`` field first, falls back to the standard URL.
    """
    article = self.get(record_id, fields=["article_url"])
    if article.get("article_url"):
        return str(article["article_url"])
    return super().url(record_id)

display_article_detail

display_article_detail(article: dict[str, Any], show_html: bool = False) -> None

Display detailed knowledge article information with body content.

Source code in src/vodoo/knowledge.py
def display_article_detail(article: dict[str, Any], show_html: bool = False) -> None:
    """Display detailed knowledge article information with body content."""
    if is_structured_output():
        structured_print(article)
        return

    if _is_simple_output():
        print(f"id: {article['id']}")
        print(f"name: {article.get('icon', '')} {article['name']}")
        if article.get("parent_id"):
            print(f"parent: {article['parent_id'][1]}")
        if article.get("category"):
            print(f"category: {article['category']}")
        if article.get("body"):
            body = article["body"] if show_html else _html_to_markdown(article["body"])
            print(f"body: {body}")
    else:
        console = _get_console()
        console.print(f"\n[bold cyan]Article #{article['id']}[/bold cyan]")
        console.print(f"[bold]Title:[/bold] {article.get('icon', '')} {article['name']}")

        if article.get("parent_id"):
            console.print(f"[bold]Parent:[/bold] {article['parent_id'][1]}")

        if article.get("category"):
            console.print(f"[bold]Category:[/bold] {article['category']}")

        if article.get("body"):
            body = article["body"]
            if show_html:
                console.print(f"\n[bold]Content:[/bold]\n{body}")
            else:
                markdown_text = _html_to_markdown(body)
                console.print(f"\n[bold]Content:[/bold]\n{markdown_text}")