diff --git a/content/contributing/development/coding_guidelines.rst b/content/contributing/development/coding_guidelines.rst index 2cdc63408..c8bd0728d 100644 --- a/content/contributing/development/coding_guidelines.rst +++ b/content/contributing/development/coding_guidelines.rst @@ -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 diff --git a/content/developer/reference/backend/orm/changelog.rst b/content/developer/reference/backend/orm/changelog.rst index e2d4fcbb0..6e26fd97d 100644 --- a/content/developer/reference/backend/orm/changelog.rst +++ b/content/developer/reference/backend/orm/changelog.rst @@ -11,6 +11,8 @@ Odoo Online version 18.2 `formatted_read_group` as formatted public API. See `#163300 `_. - `@api.private` is added to distinguish public Python methods from methods exposed for RPC calls. See `#195402 `_. +- Native namespaces for ``odoo`` module `PEP-420 `_. + See `#195664 `_. Odoo Online version 18.1 ======================== diff --git a/extensions/autodoc_field/__init__.py b/extensions/autodoc_field/__init__.py index 4f14b56c2..1ab3b7808 100644 --- a/extensions/autodoc_field/__init__.py +++ b/extensions/autodoc_field/__init__.py @@ -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: diff --git a/extensions/github_link/__init__.py b/extensions/github_link/__init__.py index 3993d538b..baa9c0077 100644 --- a/extensions/github_link/__init__.py +++ b/extensions/github_link/__init__.py @@ -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,