summaryrefslogtreecommitdiff
path: root/odoo/models.py
diff options
context:
space:
mode:
authorJulien Castiaux <juc@odoo.com>2020-03-03 15:34:07 +0000
committerRaphael Collet <rco@odoo.com>2020-05-14 14:40:02 +0000
commitd6d0e8d6d28f342a1aa88b31bc6344a371bfcece (patch)
tree6bf3caa0d6ae83631212058f22dc342c3ae4fdee /odoo/models.py
parent975deb21da316816c09e08167d0bfcecacfcea80 (diff)
[FIX] models.py: remove leftover `import crm` like compatibility
Historically, it was possible to import addons via a naked import. It is no more possible since 9e1f13bac, since that commit, the only possible way to import odoo addons is via the `import odoo.addons' prefix. closes odoo/odoo#46995 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/models.py')
-rw-r--r--odoo/models.py19
1 files changed, 3 insertions, 16 deletions
diff --git a/odoo/models.py b/odoo/models.py
index 6a1aefd3693..43f477fb1c2 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -158,31 +158,18 @@ class MetaModel(api.Meta):
return
if not hasattr(self, '_module'):
- self._module = self._get_addon_name(self.__module__)
+ assert self.__module__.startswith('odoo.addons.'), \
+ "Invalid import of %s.%s, it should start with 'odoo.addons'." % (self.__module__, name)
+ self._module = self.__module__.split('.')[2]
# Remember which models to instanciate for this module.
if self._module:
self.module_to_models[self._module].append(self)
- # check for new-api conversion error: leave comma after field definition
for key, val in attrs.items():
- if type(val) is tuple and len(val) == 1 and isinstance(val[0], Field):
- _logger.error("Trailing comma after field definition: %s.%s", self, key)
if isinstance(val, Field):
val.args['_module'] = self._module
- def _get_addon_name(self, full_name):
- # The (OpenERP) module name can be in the ``odoo.addons`` namespace
- # or not. For instance, module ``sale`` can be imported as
- # ``odoo.addons.sale`` (the right way) or ``sale`` (for backward
- # compatibility).
- module_parts = full_name.split('.')
- if len(module_parts) > 2 and module_parts[:2] == ['odoo', 'addons']:
- addon_name = full_name.split('.')[2]
- else:
- addon_name = full_name.split('.')[0]
- return addon_name
-
class NewId(object):
""" Pseudo-ids for new records, encapsulating an optional origin id (actual