Towards idiomatic Python with types for the Odoo ORM
Project description
typodoo
Towards idiomatic Python with types for Odoo models.
/!\ This is pre-alpha stuff /!\
Usage
pip install typodoo
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, extends=True):
friend: bool = fields.Boolean()
industry2_id: ResPartnerIndustry = fields.Many2one(
string='Secondary Industry',
required=True,
)
But 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
.
Make this done automatically by the build backend is a TODO.
License
typodoo
is distributed under the terms of the
MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
typodoo-0.1.tar.gz
(4.7 kB
view hashes)
Built Distribution
typodoo-0.1-py3-none-any.whl
(4.1 kB
view hashes)