Maintainers
+Maintainers
This module is maintained by the OCA.
@@ -476,6 +463,5 @@ This addon provides a utility method that can be used to map odoo record -to a Pydantic model.
+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
+and the odoo addon +extendableTable of contents
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 a utility class -odoo.addons.pydantic.utils.GenericOdooGetter.
+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:
-import pydantic -from odoo.addons.pydantic import utils +from odoo.addons.pydantic.utils import PydanticOdooBaseModel -class Group(pydantic.BaseModel): - name: str - class Config: - orm_mode = True - getter_dict = utils.GenericOdooGetter +class Group(PydanticOdooBaseModel): + name: str -class UserInfo(pydantic.BaseModel): +class UserInfo(PydanticOdooBaseModel): name: str groups: List[Group] = pydantic.Field(alias="groups_id") - class Config: - orm_mode = True - getter_dict = utils.GenericOdooGetter - user = self.env.user user_info = UserInfo.from_orm(user)-
See the official Pydantic -documentation to discover all -the available functionalities.
+See the official Pydantic documentation +to discover all the available functionalities.
The
roadmap
and known
@@ -438,7 +424,7 @@ Known issues / Roadmap
can be found on GitHub.
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -446,22 +432,23 @@
Do not contact contributors directly about support or help with technical issues.