summaryrefslogtreecommitdiff
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
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>
-rw-r--r--addons/google_calendar/controllers/main.py2
-rw-r--r--addons/google_calendar/models/calendar_recurrence_rule.py2
-rw-r--r--addons/google_calendar/models/google_sync.py6
-rw-r--r--addons/google_calendar/models/res_users.py4
-rw-r--r--addons/google_calendar/tests/test_sync_google2odoo.py2
-rw-r--r--addons/google_calendar/tests/test_sync_odoo2google.py2
-rw-r--r--addons/google_calendar/utils/google_calendar.py4
-rw-r--r--addons/google_calendar/wizard/reset_account.py4
-rw-r--r--odoo/models.py19
9 files changed, 16 insertions, 29 deletions
diff --git a/addons/google_calendar/controllers/main.py b/addons/google_calendar/controllers/main.py
index 76326eb9d85..99ed0b0b2a1 100644
--- a/addons/google_calendar/controllers/main.py
+++ b/addons/google_calendar/controllers/main.py
@@ -3,7 +3,7 @@
from odoo import http
from odoo.http import request
-from addons.google_calendar.utils.google_calendar import GoogleCalendarService
+from odoo.addons.google_calendar.utils.google_calendar import GoogleCalendarService
class GoogleCalendarController(http.Controller):
diff --git a/addons/google_calendar/models/calendar_recurrence_rule.py b/addons/google_calendar/models/calendar_recurrence_rule.py
index c09caef4be1..bf5fb65f56c 100644
--- a/addons/google_calendar/models/calendar_recurrence_rule.py
+++ b/addons/google_calendar/models/calendar_recurrence_rule.py
@@ -5,7 +5,7 @@ import re
from odoo import api, fields, models
-from addons.google_calendar.utils.google_calendar import GoogleCalendarService
+from odoo.addons.google_calendar.utils.google_calendar import GoogleCalendarService
class RecurrenceRule(models.Model):
diff --git a/addons/google_calendar/models/google_sync.py b/addons/google_calendar/models/google_sync.py
index 377aaac6a61..9957bdad6cc 100644
--- a/addons/google_calendar/models/google_sync.py
+++ b/addons/google_calendar/models/google_sync.py
@@ -13,9 +13,9 @@ from odoo.tools import ormcache_context
from odoo.exceptions import UserError
from odoo.osv import expression
-from addons.google_calendar.utils.google_event import GoogleEvent
-from addons.google_calendar.utils.google_calendar import GoogleCalendarService
-from addons.google_account.models.google_service import TIMEOUT
+from odoo.addons.google_calendar.utils.google_event import GoogleEvent
+from odoo.addons.google_calendar.utils.google_calendar import GoogleCalendarService
+from odoo.addons.google_account.models.google_service import TIMEOUT
_logger = logging.getLogger(__name__)
diff --git a/addons/google_calendar/models/res_users.py b/addons/google_calendar/models/res_users.py
index 70c2079184b..c2d2dfaf9ac 100644
--- a/addons/google_calendar/models/res_users.py
+++ b/addons/google_calendar/models/res_users.py
@@ -3,7 +3,7 @@
import logging
import requests
-from addons.google_calendar.models.google_sync import google_calendar_token
+from odoo.addons.google_calendar.models.google_sync import google_calendar_token
from datetime import timedelta
@@ -11,7 +11,7 @@ from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.loglevels import exception_to_unicode
from odoo.addons.google_account.models.google_service import GOOGLE_TOKEN_ENDPOINT
-from addons.google_calendar.utils.google_calendar import GoogleCalendarService, InvalidSyncToken
+from odoo.addons.google_calendar.utils.google_calendar import GoogleCalendarService, InvalidSyncToken
_logger = logging.getLogger(__name__)
diff --git a/addons/google_calendar/tests/test_sync_google2odoo.py b/addons/google_calendar/tests/test_sync_google2odoo.py
index b882d7ec7b4..bb69331ee46 100644
--- a/addons/google_calendar/tests/test_sync_google2odoo.py
+++ b/addons/google_calendar/tests/test_sync_google2odoo.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from addons.google_calendar.utils.google_calendar import GoogleEvent
+from odoo.addons.google_calendar.utils.google_calendar import GoogleEvent
import pytz
from datetime import datetime, date
from odoo.tests.common import SavepointCase, new_test_user
diff --git a/addons/google_calendar/tests/test_sync_odoo2google.py b/addons/google_calendar/tests/test_sync_odoo2google.py
index ae40fe9c57a..7862b1cfaa6 100644
--- a/addons/google_calendar/tests/test_sync_odoo2google.py
+++ b/addons/google_calendar/tests/test_sync_odoo2google.py
@@ -10,7 +10,7 @@ from odoo.addons.google_calendar.utils.google_calendar import GoogleCalendarServ
from odoo.addons.google_calendar.models.res_users import User
from odoo.addons.google_calendar.models.google_sync import GoogleSync
from odoo.modules.registry import Registry
-from addons.google_account.models.google_service import TIMEOUT
+from odoo.addons.google_account.models.google_service import TIMEOUT
def patch_api(func):
diff --git a/addons/google_calendar/utils/google_calendar.py b/addons/google_calendar/utils/google_calendar.py
index 20032241362..20f30d33a7f 100644
--- a/addons/google_calendar/utils/google_calendar.py
+++ b/addons/google_calendar/utils/google_calendar.py
@@ -8,8 +8,8 @@ import logging
from odoo import api, _
from odoo.tools import exception_to_unicode
-from addons.google_calendar.utils.google_event import GoogleEvent
-from addons.google_account.models.google_service import TIMEOUT
+from odoo.addons.google_calendar.utils.google_event import GoogleEvent
+from odoo.addons.google_account.models.google_service import TIMEOUT
_logger = logging.getLogger(__name__)
diff --git a/addons/google_calendar/wizard/reset_account.py b/addons/google_calendar/wizard/reset_account.py
index e942ecba34c..4a7242126d9 100644
--- a/addons/google_calendar/wizard/reset_account.py
+++ b/addons/google_calendar/wizard/reset_account.py
@@ -3,8 +3,8 @@
from odoo import fields, models
-from addons.google_calendar.models.google_sync import google_calendar_token
-from addons.google_calendar.utils.google_calendar import GoogleCalendarService
+from odoo.addons.google_calendar.models.google_sync import google_calendar_token
+from odoo.addons.google_calendar.utils.google_calendar import GoogleCalendarService
class ResetGoogleAccount(models.TransientModel):
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