[IMP] core: move class Query to odoo.tools
Move the definition of class Query to odoo.tools, in order to avoid circular imports when importing Query in core Odoo modules. Also reorganize imports in the impacted modules. Part-of: odoo/odoo#66938
This commit is contained in:
@@ -10,10 +10,9 @@ from werkzeug.urls import url_encode
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.osv.query import Query
|
||||
from odoo.exceptions import ValidationError, AccessError
|
||||
from odoo.osv import expression
|
||||
from odoo.tools.misc import format_date
|
||||
from odoo.tools import format_date, Query
|
||||
|
||||
|
||||
class HrEmployeePrivate(models.Model):
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
from random import randint
|
||||
|
||||
from odoo import api, fields, models, tools, SUPERUSER_ID
|
||||
from odoo.osv.query import Query
|
||||
from odoo.tools.translate import _
|
||||
from odoo.exceptions import AccessError, UserError
|
||||
from odoo.tools import Query
|
||||
from odoo.tools.translate import _
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import json
|
||||
from odoo import api, fields, models, _, _lt
|
||||
from odoo.exceptions import ValidationError, AccessError
|
||||
from odoo.osv import expression
|
||||
from odoo.osv.query import Query
|
||||
from odoo.tools import Query
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.osv.query import Query
|
||||
from odoo.tests.common import BaseCase
|
||||
from odoo.tools import Query
|
||||
|
||||
|
||||
class QueryTestCase(BaseCase):
|
||||
|
||||
+11
-12
@@ -44,7 +44,8 @@ from operator import attrgetter, itemgetter
|
||||
|
||||
import babel.dates
|
||||
import dateutil.relativedelta
|
||||
import psycopg2, psycopg2.extensions
|
||||
import psycopg2
|
||||
import psycopg2.extensions
|
||||
from lxml import etree
|
||||
from lxml.builder import E
|
||||
|
||||
@@ -53,17 +54,15 @@ from . import SUPERUSER_ID
|
||||
from . import api
|
||||
from . import tools
|
||||
from .exceptions import AccessError, MissingError, ValidationError, UserError
|
||||
from .osv.query import Query
|
||||
from .tools import frozendict, lazy_classproperty, ormcache, \
|
||||
LastOrderedSet, OrderedSet, ReversedIterable, \
|
||||
unique, discardattr, partition
|
||||
from .tools.config import config
|
||||
from .tools import (
|
||||
clean_context, config, CountingStream, date_utils, discardattr,
|
||||
DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, frozendict,
|
||||
get_lang, LastOrderedSet, lazy_classproperty, OrderedSet, ormcache,
|
||||
partition, populate, Query, ReversedIterable, split_every, unique,
|
||||
)
|
||||
from .tools.func import frame_codeinfo
|
||||
from .tools.misc import CountingStream, clean_context, DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT, get_lang, split_every
|
||||
from .tools.translate import _, _lt
|
||||
from .tools import date_utils
|
||||
from .tools import populate
|
||||
from .tools.lru import LRU
|
||||
from .tools.translate import _, _lt
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_unlink = logging.getLogger(__name__ + '.unlink')
|
||||
@@ -2315,7 +2314,7 @@ class BaseModel(metaclass=MetaModel):
|
||||
These dictionaries contain the qualified name of each groupby
|
||||
(fully qualified SQL name for the corresponding field),
|
||||
and the (non raw) field name.
|
||||
:param osv.Query query: the query under construction
|
||||
:param Query query: the query under construction
|
||||
:return: (groupby_terms, orderby_terms)
|
||||
"""
|
||||
orderby_terms = []
|
||||
@@ -4616,7 +4615,7 @@ class BaseModel(metaclass=MetaModel):
|
||||
:param bool active_test: whether the default filtering of records with
|
||||
``active`` field set to ``False`` should be applied.
|
||||
:return: the query expressing the given domain as provided in domain
|
||||
:rtype: osv.query.Query
|
||||
:rtype: Query
|
||||
"""
|
||||
# if the object has an active field ('active', 'x_active'), filter out all
|
||||
# inactive records unless they were explicitly asked for
|
||||
|
||||
@@ -114,23 +114,17 @@ start the server specifying the ``--unaccent`` flag.
|
||||
|
||||
"""
|
||||
import collections.abc
|
||||
import warnings
|
||||
|
||||
import logging
|
||||
import reprlib
|
||||
import traceback
|
||||
from functools import partial
|
||||
|
||||
import warnings
|
||||
from datetime import date, datetime, time
|
||||
|
||||
from psycopg2.sql import Composable, SQL
|
||||
|
||||
import odoo.modules
|
||||
from odoo.osv.query import Query, _generate_table_alias
|
||||
from odoo.tools import pycompat
|
||||
from odoo.tools.misc import get_lang
|
||||
from ..models import MAGIC_COLUMNS, BaseModel
|
||||
import odoo.tools as tools
|
||||
from ..models import BaseModel
|
||||
from odoo.tools import pycompat, Query, _generate_table_alias
|
||||
|
||||
|
||||
# Domain operators.
|
||||
|
||||
+14
-13
@@ -2,24 +2,25 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import _monkeypatches
|
||||
from . import appdirs
|
||||
from . import cloc
|
||||
from . import pdf
|
||||
from . import pycompat
|
||||
from . import win32
|
||||
from . import appdirs
|
||||
from . import pdf
|
||||
from . import cloc
|
||||
from .config import config
|
||||
from .misc import *
|
||||
from .translate import *
|
||||
from .image import *
|
||||
from .sql import *
|
||||
from .float_utils import *
|
||||
from .mail import *
|
||||
from .func import *
|
||||
from .debugger import *
|
||||
from .xml_utils import *
|
||||
from .date_utils import *
|
||||
from .convert import *
|
||||
from .debugger import *
|
||||
from .float_utils import *
|
||||
from .func import *
|
||||
from .image import *
|
||||
from .mail import *
|
||||
from .misc import *
|
||||
from .query import Query, _generate_table_alias
|
||||
from .sql import *
|
||||
from .template_inheritance import *
|
||||
from .translate import *
|
||||
from .xml_utils import *
|
||||
from .convert import *
|
||||
from . import osutil
|
||||
from .js_transpiler import transpile_javascript, is_odoo_module, URL_RE, ODOO_MODULE_RE
|
||||
from .sourcemap_generator import SourceMapGenerator
|
||||
|
||||
@@ -5,8 +5,8 @@ from datetime import date, datetime, time
|
||||
import pytz
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from . import ustr
|
||||
from .func import lazy
|
||||
from odoo.loglevels import ustr
|
||||
|
||||
def get_month(date):
|
||||
''' Compute the month dates range on which the 'date' parameter belongs to.
|
||||
|
||||
@@ -5,7 +5,7 @@ import re
|
||||
import warnings
|
||||
from zlib import crc32
|
||||
|
||||
from odoo.tools import lazy_property
|
||||
from .func import lazy_property
|
||||
|
||||
IDENT_RE = re.compile(r'^[a-z_][a-z0-9_$]*$', re.I)
|
||||
|
||||
@@ -137,7 +137,7 @@ class Query(object):
|
||||
""" Add a LEFT JOIN to the current table (if necessary), and return the
|
||||
alias corresponding to ``rhs_table``.
|
||||
|
||||
See the documentation of :meth:`~odoo.osv.query.Query.join` for a better overview of the
|
||||
See the documentation of :meth:`join` for a better overview of the
|
||||
arguments and what they do.
|
||||
"""
|
||||
return self._join('LEFT JOIN', lhs_alias, lhs_column, rhs_table, rhs_column, link, extra, extra_params)
|
||||
Reference in New Issue
Block a user