Towards idiomatic Python with types for the Odoo ORM
Project description
typodoo
Towards idiomatic Python with types for Odoo models.
This package supports the Odoo Experience 2022 talk (sildes, video).
It works best when a few type annotations are added to the Odoo core.
/!\ This is pre-alpha stuff /!\
What?
pip install typodoo to monkey patch the Odoo metaclass on Odoo startup.
Then, you can still write this, as usual:
from odoo import models, fields
class ResPartner(models.Model):
_inherit = "res.partner"
friend = fields.Boolean()
industry2_id = fields.Many2one(
'res.partner.industry',
string='Secondary Industry',
required=True,
)
But you can also write this:
from odoo import fields
from odoo.addons.base.models.res_partner import (
Partner, ResPartnerIndustry
)
class ResPartner(Partner):
friend = fields.Boolean()
industry2_id = fields.Many2one[ResPartnerIndustry](
string='Secondary Industry',
)
And also this:
from odoo.addons.my_addon.models.res_partner import ResPartner
partners = ResPartner(self.env).search([])
Why?
Idiomatic python.
Native auto completion in IDEs.
Static type checking.
Development
pip install -e .
Then, copy typodoo_activate.pth to $VIRTUAL_ENV/lib/python3.10/site-packages.
Automating this setup is a TODO.
License
typodoo is distributed under the terms of the
MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file typodoo-0.4.1.tar.gz.
File metadata
- Download URL: typodoo-0.4.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a5167f9fd5613f0489d9cc809cba00a3574bf1d8c7755071355feb8f1ead2dd
|
|
| MD5 |
8f967b85ca9a95806bcefb4f8dfc2a00
|
|
| BLAKE2b-256 |
2f19191b8ddb3a655a9f0fec80237284327cf31c7d1e8dd3801bf196ef124df4
|
Provenance
The following attestation bundles were made for typodoo-0.4.1.tar.gz:
Publisher:
release.yml on sbidoul/typodoo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typodoo-0.4.1.tar.gz -
Subject digest:
4a5167f9fd5613f0489d9cc809cba00a3574bf1d8c7755071355feb8f1ead2dd - Sigstore transparency entry: 150742137
- Sigstore integration time:
-
Permalink:
sbidoul/typodoo@b7571590ca7122398844d576f1edd5af8a1c034b -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/sbidoul
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b7571590ca7122398844d576f1edd5af8a1c034b -
Trigger Event:
release
-
Statement type:
File details
Details for the file typodoo-0.4.1-py3-none-any.whl.
File metadata
- Download URL: typodoo-0.4.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36123f7184398cf4e741e163ff9ef904cdf242ef51a90190665e1f5f0e6c511e
|
|
| MD5 |
0403b23499657d02504e9525ccdaadbb
|
|
| BLAKE2b-256 |
6934670e5d5753e006ca6a56e37f8293e60bf862ff2fe3b89d18adec18777192
|
Provenance
The following attestation bundles were made for typodoo-0.4.1-py3-none-any.whl:
Publisher:
release.yml on sbidoul/typodoo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typodoo-0.4.1-py3-none-any.whl -
Subject digest:
36123f7184398cf4e741e163ff9ef904cdf242ef51a90190665e1f5f0e6c511e - Sigstore transparency entry: 150742138
- Sigstore integration time:
-
Permalink:
sbidoul/typodoo@b7571590ca7122398844d576f1edd5af8a1c034b -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/sbidoul
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b7571590ca7122398844d576f1edd5af8a1c034b -
Trigger Event:
release
-
Statement type: