mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 23:12:01 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
* Laurent Mignon <laurent.mignon@acsone.eu>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
This addon provides a utility method that can be used to map odoo record
|
||||
to a `Pydantic model <https://pydantic-docs.helpmanual.io/>`_.
|
||||
|
||||
If you need to make your Pydantic models extendable at runtime, takes a look
|
||||
at the python package `extendable-pydantic <https://pypi.org/project/extendable_pydantic/>`_
|
||||
and the odoo addon `extendable <https://github.com/acsone/odoo-addon-extendable>`_
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
The `roadmap <https://github.com/OCA/rest-framework/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement+label%3Apydantic>`_
|
||||
and `known issues <https://github.com/OCA/rest-framework/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apydantic>`_ can
|
||||
be found on GitHub.
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
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`.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import pydantic
|
||||
from odoo.addons.pydantic import utils
|
||||
|
||||
class Group(pydantic.BaseModel):
|
||||
name: str
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
getter_dict = utils.GenericOdooGetter
|
||||
|
||||
class UserInfo(pydantic.BaseModel):
|
||||
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.
|
||||
|
||||
.. _`Pydantic documentation`: https://pydantic-docs.helpmanual.io/
|
||||
Loading…
Add table
Add a link
Reference in a new issue