diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f9e64907d..18638b3a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,6 @@ exclude: | ^graphql_base/| ^graphql_demo/| ^model_serializer/| - ^pydantic/| ^rest_log/| # END NOT INSTALLABLE ADDONS # Files and folders generated by bots, to avoid loops diff --git a/pydantic/README.rst b/pydantic/README.rst index d62ba17e1..6d1457a2e 100644 --- a/pydantic/README.rst +++ b/pydantic/README.rst @@ -17,23 +17,25 @@ Pydantic :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github - :target: https://github.com/OCA/rest-framework/tree/16.0/pydantic + :target: https://github.com/OCA/rest-framework/tree/17.0/pydantic :alt: OCA/rest-framework .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/rest-framework-16-0/rest-framework-16-0-pydantic + :target: https://translation.odoo-community.org/projects/rest-framework-17-0/rest-framework-17-0-pydantic :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| This addon provides a utility method that can be used to map odoo record -to a `Pydantic model `_. +to a `Pydantic model `__. -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 `_ +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 `__ **Table of contents** @@ -43,44 +45,47 @@ and the odoo addon `extendable Usage ===== -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`. +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 +.. code:: python - import pydantic - from odoo.addons.pydantic import utils + import pydantic + from odoo.addons.pydantic import utils - class Group(pydantic.BaseModel): - name: str + class Group(pydantic.BaseModel): + name: str - class Config: - orm_mode = True - getter_dict = utils.GenericOdooGetter + class Config: + orm_mode = True + getter_dict = utils.GenericOdooGetter - class UserInfo(pydantic.BaseModel): - name: str - groups: List[Group] = pydantic.Field(alias="groups_id") + class UserInfo(pydantic.BaseModel): + name: str + groups: List[Group] = pydantic.Field(alias="groups_id") - class Config: - orm_mode = True - getter_dict = utils.GenericOdooGetter + class Config: + orm_mode = True + getter_dict = utils.GenericOdooGetter - user = self.env.user - user_info = UserInfo.from_orm(user) + 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/ +See the official `Pydantic +documentation `__ to discover all +the available functionalities. Known issues / Roadmap ====================== -The `roadmap `_ -and `known issues `_ can -be found on GitHub. +The +`roadmap `__ +and `known +issues `__ +can be found on GitHub. Bug Tracker =========== @@ -88,7 +93,7 @@ Bug Tracker 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 -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -96,17 +101,18 @@ Credits ======= Authors -~~~~~~~ +------- * ACSONE SA/NV Contributors -~~~~~~~~~~~~ +------------ -* Laurent Mignon +- Laurent Mignon +- Tris Doan Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -126,6 +132,6 @@ Current `maintainer `__: |maintainer-lmignon| -This module is part of the `OCA/rest-framework `_ project on GitHub. +This module is part of the `OCA/rest-framework `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pydantic/__manifest__.py b/pydantic/__manifest__.py index 6cc4b4f68..494fee526 100644 --- a/pydantic/__manifest__.py +++ b/pydantic/__manifest__.py @@ -5,7 +5,7 @@ "name": "Pydantic", "summary": """ Utility addon to ease mapping between Pydantic and Odoo models""", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "development_status": "Beta", "license": "LGPL-3", "maintainers": ["lmignon"], @@ -17,5 +17,5 @@ "external_dependencies": { "python": ["pydantic", "contextvars", "typing-extensions"] }, - "installable": False, + "installable": True, } diff --git a/pydantic/pyproject.toml b/pydantic/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/pydantic/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pydantic/readme/CONTRIBUTORS.md b/pydantic/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..9b84ef6d3 --- /dev/null +++ b/pydantic/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Laurent Mignon \<\> +- Tris Doan \<\> diff --git a/pydantic/readme/CONTRIBUTORS.rst b/pydantic/readme/CONTRIBUTORS.rst deleted file mode 100644 index 172b2d223..000000000 --- a/pydantic/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1 +0,0 @@ -* Laurent Mignon diff --git a/pydantic/readme/DESCRIPTION.md b/pydantic/readme/DESCRIPTION.md new file mode 100644 index 000000000..83b7baff0 --- /dev/null +++ b/pydantic/readme/DESCRIPTION.md @@ -0,0 +1,8 @@ +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) diff --git a/pydantic/readme/DESCRIPTION.rst b/pydantic/readme/DESCRIPTION.rst deleted file mode 100644 index f401c8037..000000000 --- a/pydantic/readme/DESCRIPTION.rst +++ /dev/null @@ -1,6 +0,0 @@ -This addon provides a utility method that can be used to map odoo record -to a `Pydantic model `_. - -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 `_ diff --git a/pydantic/readme/ROADMAP.md b/pydantic/readme/ROADMAP.md new file mode 100644 index 000000000..d9d2e425c --- /dev/null +++ b/pydantic/readme/ROADMAP.md @@ -0,0 +1,5 @@ +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. diff --git a/pydantic/readme/ROADMAP.rst b/pydantic/readme/ROADMAP.rst deleted file mode 100644 index 0778bc3aa..000000000 --- a/pydantic/readme/ROADMAP.rst +++ /dev/null @@ -1,3 +0,0 @@ -The `roadmap `_ -and `known issues `_ can -be found on GitHub. diff --git a/pydantic/readme/USAGE.md b/pydantic/readme/USAGE.md new file mode 100644 index 000000000..92327bb6a --- /dev/null +++ b/pydantic/readme/USAGE.md @@ -0,0 +1,32 @@ +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. + +``` 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](https://pydantic-docs.helpmanual.io/) to discover all the +available functionalities. diff --git a/pydantic/readme/USAGE.rst b/pydantic/readme/USAGE.rst deleted file mode 100644 index f52f1c594..000000000 --- a/pydantic/readme/USAGE.rst +++ /dev/null @@ -1,31 +0,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 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/ diff --git a/pydantic/static/description/index.html b/pydantic/static/description/index.html index 91cd586f1..e8083ea5a 100644 --- a/pydantic/static/description/index.html +++ b/pydantic/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,12 +369,14 @@

Pydantic

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:dfff59b19d2faa3595976c86a0480fc8f5b7112148ad7de50cccdb6faa610aa8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-3 OCA/rest-framework Translate me on Weblate Try me on Runboat

+

Beta License: LGPL-3 OCA/rest-framework Translate me on Weblate Try me on Runboat

This addon provides a utility method that can be used to map odoo record to a Pydantic model.

-

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

+

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

Table of contents

    @@ -391,10 +393,11 @@

    Pydantic

Usage

-

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.

+

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.

 import pydantic
 from odoo.addons.pydantic import utils
@@ -417,20 +420,24 @@ 

Usage

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.

Known issues / Roadmap

-

The roadmap -and known issues can -be found on GitHub.

+

The +roadmap +and known +issues +can be found on GitHub.

Bug Tracker

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 -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -445,18 +452,21 @@

Authors

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainer:

lmignon

-

This module is part of the OCA/rest-framework project on GitHub.

+

This module is part of the OCA/rest-framework project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/requirements.txt b/requirements.txt index bcba9b734..058f53dad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,9 @@ # generated from manifests external_dependencies a2wsgi>=1.10.6 +contextvars fastapi>=0.110.0 parse-accept-language +pydantic python-multipart +typing-extensions ujson