OdooWiki OCA HUB

Search Engine Serilizer Pydantic

search_engine_serializer_pydantic folder_open OCA/search-engine open_in_new
Uncategorised License: AGPL-3

This module is a technical module that define a new abstract class named PydandicModelSerializer that inherit from odoo.addons.connector_search_engine.tools.serializer.ModelSerializer

This new class define a new abstract method get_model_class. This method is used by the index to get the Pydantic model class to use to generate the json schema.

On the index form, if the serializer is a PydanticModelSerializer, a field is displayed to display the related json schema and therefore provide documentation about the fields exported and their characteristics.

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

Adds a Pydantic section to the search engine index form that shows the JSON schema of the records stored in the index when the index uses a Pydantic-based serializer.

This is a technical module that extends the search engine index configuration screen (se.index). It does not add new menus; it adds a "Pydantic" group inside the existing index form, right after the configuration group.

  • When the serializer selected on the index is based on a Pydantic model, the form shows a read-only code editor displaying the JSON schema of a record stored in that index. This helps developers and integrators see which fields are exported and what their characteristics are.
  • When the serializer is not Pydantic-based, the Pydantic group is hidden and the schema fields are empty.
  • Two computed fields support this: one boolean that tells whether the serializer is a Pydantic serializer, and one text field holding the JSON schema. Both are computed from the index's serializer type and are not stored in the database.
  • The module also defines an abstract serializer base class with a method that returns the Pydantic model class used to generate the schema. Concrete serializers must implement it.

It touches the se.index model and depends on the search engine connector and the Python pydantic library.

Required by other modules

Models and fields (1)
  • se.index · extends an existing modelrecord_json_schema (JSON Schema of a record stored in this index (as dict)), is_pydantic_serializer (Is a Serializer based on Pydantic Model?), record_json_schema_str (JSON Schema of a record stored in this index)

Text generated by AI (DeepSeek) from reading the Odoo 18.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 2 confirmed, 7 with no information of 9 versions.

Sources · Odoo 18.0

Confirmed on 2026-11-03 in branch 18.0 of OCA/search-engine.

terminal Installation and usage

OCA documentation · Odoo 18.0

When you define a serializer based on a Pydantic model, your serializer class must inherit from PydanticModelSerializer and implement the method get_model_class to take advantage of the functionality provided by this module.

Example:

from typing import Type
from pydantic import BaseModel

from odoo.addons.search_engine_serialize_pydantic.tools.serializer import (
    PydanticModelSerializer,
)


class MyModel(BaseModel):
    name: str
    description: str

    def record_to_model(self, record: Model) -> dict:
        return cls(
            name=record.name,
            description=record.description,
        )

class MyModelSerializer(PydanticModelSerializer):
    def get_model_class(self) -> Type[MyModel]:
        return MyModel

    def serialize(self, record: Model) -> dict:
        model: MyModel = self.get_model_class().record_to_model(record)
        return model.model_dump()

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.