[IMP] core: PEP420 native namespace

task-4035335

closes odoo/documentation#11914

Related: odoo/odoo#195664
Signed-off-by: Krzysztof Magusiak (krma) <krma@odoo.com>
This commit is contained in:
Krzysztof Magusiak (krma) 2025-01-25 09:21:03 +00:00
parent ee5a13730d
commit 4b9939c579
4 changed files with 16 additions and 12 deletions

View File

@ -411,8 +411,8 @@ Imports
The imports are ordered as
#. External libraries (one per line sorted and split in python stdlib)
#. Imports of ``odoo``
#. Imports from Odoo modules (rarely, and only if necessary)
#. Imports of ``odoo`` submodules
#. Imports from Odoo addons (rarely, and only if necessary)
Inside these 3 groups, the imported lines are alphabetically sorted.
@ -424,8 +424,8 @@ Inside these 3 groups, the imported lines are alphabetically sorted.
import time
from datetime import datetime
# 2 : imports of odoo
import odoo
from odoo import api, fields, models, _ # alphabetically ordered
from odoo import api, fields, models # alphabetically ordered
from odoo.fields import Domain
from odoo.tools.safe_eval import safe_eval as eval
# 3 : imports from odoo addons
from odoo.addons.web.controllers.main import login_redirect

View File

@ -11,6 +11,8 @@ Odoo Online version 18.2
`formatted_read_group` as formatted public API. See `#163300 <https://github.com/odoo/odoo/pull/163300>`_.
- `@api.private` is added to distinguish public Python methods from methods exposed for RPC calls.
See `#195402 <https://github.com/odoo/odoo/pull/195402>`_.
- Native namespaces for ``odoo`` module `PEP-420 <https://peps.python.org/pep-0420/>`_.
See `#195664 <https://github.com/odoo/odoo/pull/195664>`_.
Odoo Online version 18.1
========================

View File

@ -6,8 +6,6 @@ from docutils.parsers.rst.states import RSTState
from sphinx.domains.python import PyAttribute, PyClasslike
from sphinx.ext.autodoc import AttributeDocumenter, ClassDocumenter
import odoo
nested_parse = RSTState.nested_parse
def patched_nested_parse(self, block, input_offset, node, match_titles=False,
state_machine_class=None, state_machine_kwargs=None):
@ -23,7 +21,8 @@ class OdooClassDocumenter(ClassDocumenter):
@classmethod
def can_document_member(cls, member, membername, isattr, parent):
return isinstance(member, odoo.models.MetaModel)
from odoo.models import MetaModel
return isinstance(member, MetaModel)
def add_content(self, more_content):
sourcename = self.get_sourcename()
@ -56,7 +55,8 @@ class FieldDocumenter(AttributeDocumenter):
@classmethod
def can_document_member(cls, member, membername, isattr, parent):
return isinstance(member, odoo.fields.Field)
from odoo.fields import Field
return isinstance(member, Field)
def update_annotations(self, parent):
super().update_annotations(parent)
@ -67,7 +67,8 @@ class FieldDocumenter(AttributeDocumenter):
if field.type == 'many2one':
annotation[attrname] = int
elif field.type in ('one2many', 'many2many'):
annotation[attrname] = Sequence[odoo.fields.Command]
from odoo.fields import Command
annotation[attrname] = Sequence[Command]
elif field.type in ('selection', 'reference', 'char', 'text', 'html'):
annotation[attrname] = str
elif field.type == 'boolean':
@ -104,7 +105,8 @@ class FieldDocumenter(AttributeDocumenter):
if reference:
self.add_line(f":possible_values: `{reference} <{self.config.source_read_replace_vals['GITHUB_PATH']}/{reference}>`__", source_name)
if field.default:
self.add_line(f":default: {field.default(odoo.models.Model)}", source_name)
from odoo.models import Model
self.add_line(f":default: {field.default(Model)}", source_name)
super().add_content(more_content)
if field.help:

View File

@ -71,9 +71,9 @@ def setup(app):
project = 'upgrade-util'
project_root = os.path.join(os.path.dirname(util.__file__), '../..')
else:
import odoo
from odoo import release
project = 'odoo'
project_root = os.path.join(os.path.dirname(odoo.__file__), '..')
project_root = os.path.join(os.path.dirname(release.__file__), '..')
return make_github_link(
app,
project=project,