Skip to content

API Reference parrot_tools.odoo.smart_fields

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.odoo.smart_fields

View source

Smart field selection heuristic for OdooToolkit.

When an agent omits fields in search_records or get_record, Odoo returns every field on the model — including binary blobs, HTML columns, audit timestamps, and dozens of technical relational fields that flood the LLM context with irrelevant noise.

This module provides :func:select_smart_fields, a pure function (no I/O, no async) that scores a fields_get metadata dict and returns the top N most "agent-useful" field names.

Inspired by the tuanle96/mcp-odoo project's scoring heuristic.

Attribute HIGH_VALUE_PATTERNS

Type: tuple[str, ...]

Attribute SKIP_FIELD_TYPES

Type: frozenset[str]

Attribute TECHNICAL_FIELD_NAMES

Type: frozenset[str]

Function select_smart_fields

Select the most LLM-useful fields from an Odoo fields_get response.

Example::

meta = await toolkit.fields_get("res.partner")
fields = select_smart_fields(meta, max_fields=10)
# ["id", "display_name", "name", "email", "phone", ...]

select_smart_fields(fields_metadata: dict[str, Any], max_fields: int = 15, always_include: list[str] | None = None) -> list[str]

Parameter Type Default Description
fields_metadata dict[str, Any] Mapping of field_name → field_meta_dict as returned by fields_get. Each value must contain at minimum a "type" key.
max_fields int 15 Maximum number of scored fields to include (excludes id, display_name, and any entries in always_include). Defaults to 15.
always_include list[str] | None None Extra field names to always include regardless of score. These don't count against max_fields.

Returns: list[str] — Sorted list of field names. id and display_name come first (if they exist in the metadata), followed by the top-scoring fields in descending score order. Binary/HTML fields are never included.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally