[REM] core: remove deadcode from models.py
- Remove unused imports `AsIs` and `Collector` - Remove unused logger _schema - Remove unused function same_name - Remove unused attribute `_needaction` - Remove backward compatibility of `__new__` and `__init__` - Remove backward compatibility of `__export_rows` Also: - remove deprecated warning in api.py - remove the `__init__` from `ir.ui.menu`, it was useless because the cleaning of cache (`clear_caches`) is global (a call of `clear_caches` clean all cache method with a ormcache decoration) Part-of: odoo/odoo#79563
This commit is contained in:
committed by
Raphael Collet
parent
ac44685b71
commit
cbb563fd98
@@ -21,10 +21,6 @@ class IrUiMenu(models.Model):
|
||||
_order = "sequence,id"
|
||||
_parent_store = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(IrUiMenu, self).__init__(*args, **kwargs)
|
||||
self.pool['ir.model.access'].register_cache_clearing_method(self._name, 'clear_caches')
|
||||
|
||||
name = fields.Char(string='Menu', required=True, translate=True)
|
||||
active = fields.Boolean(default=True)
|
||||
sequence = fields.Integer(default=10)
|
||||
|
||||
@@ -6,6 +6,7 @@ from odoo.tests.common import TransactionCase, tagged
|
||||
|
||||
DEPRECATED_MODEL_ATTRIBUTES = [
|
||||
'view_init',
|
||||
'_needaction',
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -74,10 +74,6 @@ class Meta(type):
|
||||
if not key.startswith('__') and callable(value):
|
||||
# make the method inherit from decorators
|
||||
value = propagate(getattr(parent, key, None), value)
|
||||
|
||||
if (getattr(value, '_api', None) or '').startswith('cr'):
|
||||
_logger.warning("Deprecated method %s.%s in module %s", name, key, attrs.get('__module__'))
|
||||
|
||||
attrs[key] = value
|
||||
|
||||
return type.__new__(meta, name, bases, attrs)
|
||||
|
||||
+2
-25
@@ -46,7 +46,6 @@ import dateutil.relativedelta
|
||||
import psycopg2, psycopg2.extensions
|
||||
from lxml import etree
|
||||
from lxml.builder import E
|
||||
from psycopg2.extensions import AsIs
|
||||
|
||||
import odoo
|
||||
from . import SUPERUSER_ID
|
||||
@@ -55,7 +54,7 @@ from . import tools
|
||||
from .exceptions import AccessError, MissingError, ValidationError, UserError
|
||||
from .osv.query import Query
|
||||
from .tools import frozendict, lazy_classproperty, ormcache, \
|
||||
Collector, LastOrderedSet, OrderedSet, IterableGenerator, \
|
||||
LastOrderedSet, OrderedSet, IterableGenerator, \
|
||||
groupby, discardattr, partition
|
||||
from .tools.config import config
|
||||
from .tools.func import frame_codeinfo
|
||||
@@ -67,10 +66,9 @@ from .tools import unique
|
||||
from .tools.lru import LRU
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_schema = logging.getLogger(__name__ + '.schema')
|
||||
_unlink = logging.getLogger(__name__ + '.unlink')
|
||||
|
||||
regex_order = re.compile('^(\s*([a-z0-9:_]+|"[a-z0-9:_]+")(\s+(desc|asc))?\s*(,|$))+(?<!,)$', re.I)
|
||||
regex_order = re.compile(r'^(\s*([a-z0-9:_]+|"[a-z0-9:_]+")(\s+(desc|asc))?\s*(,|$))+(?<!,)$', re.I)
|
||||
regex_object_name = re.compile(r'^[a-z0-9_.]+$')
|
||||
regex_pg_name = re.compile(r'^[a-z_][a-z0-9_$]*$', re.I)
|
||||
regex_field_agg = re.compile(r'(\w+)(?::(\w+)(?:\((\w+)\))?)?')
|
||||
@@ -119,10 +117,6 @@ def check_method_name(name):
|
||||
if regex_private.match(name):
|
||||
raise AccessError(_('Private methods (such as %s) cannot be called remotely.') % (name,))
|
||||
|
||||
def same_name(f, g):
|
||||
""" Test whether functions ``f`` and ``g`` are identical or have the same name """
|
||||
return f == g or getattr(f, '__name__', 0) == getattr(g, '__name__', 1)
|
||||
|
||||
def fix_import_export_id_paths(fieldname):
|
||||
"""
|
||||
Fixes the id fields in import and exports, and splits field paths
|
||||
@@ -515,7 +509,6 @@ class BaseModel(metaclass=MetaModel):
|
||||
_date_name = 'date' #: field to use for default calendar view
|
||||
_fold_name = 'fold' #: field to determine folded groups in kanban views
|
||||
|
||||
_needaction = False # whether the model supports "need actions" (Old API)
|
||||
_translate = True # False disables translations export for this model (Old API)
|
||||
_check_company_auto = False
|
||||
"""On write and create, call ``_check_company`` to ensure companies
|
||||
@@ -662,10 +655,6 @@ class BaseModel(metaclass=MetaModel):
|
||||
ModelClass.pool = pool
|
||||
pool[name] = ModelClass
|
||||
|
||||
# backward compatibility: instantiate the model, and initialize it
|
||||
model = object.__new__(ModelClass)
|
||||
model.__init__(pool, cr)
|
||||
|
||||
return ModelClass
|
||||
|
||||
@classmethod
|
||||
@@ -827,15 +816,6 @@ class BaseModel(metaclass=MetaModel):
|
||||
cls._onchange_methods = methods
|
||||
return methods
|
||||
|
||||
def __new__(cls):
|
||||
# In the past, this method was registering the model class in the server.
|
||||
# This job is now done entirely by the metaclass MetaModel.
|
||||
return None
|
||||
|
||||
def __init__(self, pool, cr):
|
||||
""" Deprecated method to initialize the model. """
|
||||
pass
|
||||
|
||||
def _is_an_ordinary_table(self):
|
||||
return self.pool.is_an_ordinary_table(self)
|
||||
|
||||
@@ -1033,9 +1013,6 @@ class BaseModel(metaclass=MetaModel):
|
||||
|
||||
return lines
|
||||
|
||||
# backward compatibility
|
||||
__export_rows = _export_rows
|
||||
|
||||
def export_data(self, fields_to_export):
|
||||
""" Export fields for selected objects
|
||||
|
||||
|
||||
Reference in New Issue
Block a user