OdooWiki OCA HUB
Uncategorised License: LGPL-3

This addon provides a utility method that can be used to map odoo record to a Pydantic model (>= v2).

If you need to make your Pydantic models extendable at runtime, takes a look at the python package extendable-pydantic and the odoo addon extendable

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

This module is a technical utility that helps developers convert Odoo records into Pydantic data models, ensuring correct handling of dates, empty values, and related record identifiers.

This is a developer-oriented addon with no user interface, menus, or business rules. It provides a base class, PydanticOdooBaseModel, that developers can use to define data models for validating and serializing Odoo records.

When converting an Odoo record into such a model, the module automatically applies three corrections: - Empty values (False) on non-boolean fields become None, avoiding confusion between "no value" and "false". - Date and time fields are converted to timezone-aware values based on the record's timezone. - Many-to-one fields (links to a single record) are returned as the related record's numeric ID when the target field is declared as an integer, instead of the full record object.

The module depends on the external Python library pydantic version 2 or higher, along with contextvars and typing-extensions. It does not add any database models, views, or menus. Its purpose is to support other modules that need to exchange data between Odoo and external systems or APIs in a structured, validated way.

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: 6 confirmed, 3 with no information of 9 versions.

Sources · Odoo 17.0

Confirmed on 2026-11-03 in branch 17.0 of OCA/rest-framework.

terminal Installation and usage

OCA documentation · Odoo 18.0

To support pydantic models that map to Odoo models, Pydantic model instances can be created from arbitrary odoo model instances by mapping fields from odoo models to fields defined by the pydantic model.

To ease the mapping, the addon provide an utility class (using pydantic>2.0) odoo.addons.pydantic.utils.PydanticOdooBaseModel:

from odoo.addons.pydantic.utils import PydanticOdooBaseModel


class Group(PydanticOdooBaseModel):
    name: str

class UserInfo(PydanticOdooBaseModel):
    name: str
    groups: List[Group] = pydantic.Field(alias="groups_id")

user = self.env.user
user_info = UserInfo.from_orm(user)

See the official Pydantic documentation to discover all the available functionalities.

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.