summaryrefslogtreecommitdiff
path: root/addons/mail/controllers
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2016-08-09 16:17:17 +0200
committerThibault Delavallée <tde@openerp.com>2016-08-10 15:48:07 +0200
commitc8a313d51e57e9db52758a2c92c13044efef5a6a (patch)
tree5d213f21f33e815804206e36bf4f6c807a6a122c /addons/mail/controllers
parent5ce159924c235c06e4b1f6f653fe305932b83b5a (diff)
[IMP] various: use odoo for imports instead of openerp and update class names
Diffstat (limited to 'addons/mail/controllers')
-rw-r--r--addons/mail/controllers/bus.py16
-rw-r--r--addons/mail/controllers/main.py25
2 files changed, 21 insertions, 20 deletions
diff --git a/addons/mail/controllers/bus.py b/addons/mail/controllers/bus.py
index 0249c823ec4..c735fe6bb8d 100644
--- a/addons/mail/controllers/bus.py
+++ b/addons/mail/controllers/bus.py
@@ -1,12 +1,12 @@
-# -*- coding: utf-8 -*
-import base64
-import openerp
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from openerp import SUPERUSER_ID
-from openerp.http import request
+from odoo import SUPERUSER_ID
+from odoo.http import request, route
+from odoo.addons.bus.controllers.main import BusController
-class MailChatController(openerp.addons.bus.controllers.main.BusController):
+class MailChatController(BusController):
def _default_request_uid(self):
""" For Anonymous people, they receive the access right of SUPERUSER_ID since they have NO access (auth=none)
@@ -33,7 +33,7 @@ class MailChatController(openerp.addons.bus.controllers.main.BusController):
# --------------------------
# Anonymous routes (Common Methods)
# --------------------------
- @openerp.http.route('/mail/chat_post', type="json", auth="none")
+ @route('/mail/chat_post', type="json", auth="none")
def mail_chat_post(self, uuid, message_content, **kwargs):
request_uid = self._default_request_uid()
# find the author from the user session, which can be None
@@ -45,7 +45,7 @@ class MailChatController(openerp.addons.bus.controllers.main.BusController):
message = mail_channel.sudo(request_uid).with_context(mail_create_nosubscribe=True).message_post(author_id=author_id, email_from=False, body=message_content, message_type='comment', subtype='mail.mt_comment', content_subtype='plaintext', **kwargs)
return message and message.id or False
- @openerp.http.route(['/mail/chat_history'], type="json", auth="none")
+ @route(['/mail/chat_history'], type="json", auth="none")
def mail_chat_history(self, uuid, last_id=False, limit=20):
request_uid = self._default_request_uid()
channel = request.env["mail.channel"].sudo(request_uid).search([('uuid', '=', uuid)], limit=1)
diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py
index 399220d1875..c385153da7e 100644
--- a/addons/mail/controllers/main.py
+++ b/addons/mail/controllers/main.py
@@ -1,17 +1,18 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
import base64
import json
-from operator import itemgetter
import psycopg2
import werkzeug
-from werkzeug import url_encode
-import openerp
-from openerp import SUPERUSER_ID
-from openerp import http
-from openerp.exceptions import AccessError
-from openerp.http import request
+from operator import itemgetter
+from werkzeug import url_encode
-from openerp.addons.web.controllers.main import binary_content
+from odoo import http, registry, SUPERUSER_ID
+from odoo.addons.web.controllers.main import binary_content
+from odoo.exceptions import AccessError
+from odoo.http import request
class MailController(http.Controller):
@@ -29,9 +30,9 @@ class MailController(http.Controller):
for db in dbs:
message = dbs[db].decode('base64')
try:
- registry = openerp.registry(db)
- with registry.cursor() as cr:
- mail_thread = registry['mail.thread']
+ db_registry = registry(db)
+ with db_registry.cursor() as cr:
+ mail_thread = db_registry['mail.thread']
mail_thread.message_process(cr, SUPERUSER_ID, None, message)
except psycopg2.Error:
pass
@@ -222,7 +223,7 @@ class MailController(http.Controller):
# if the current user has access to the document, get the partner avatar as sudo()
request.env[res_model].browse(res_id).check_access_rule('read')
if partner_id in request.env[res_model].browse(res_id).sudo().exists().message_ids.mapped('author_id').ids:
- status, headers, _content = binary_content(model='res.partner', id=partner_id, field='image_medium', default_mimetype='image/png', env=request.env(user=openerp.SUPERUSER_ID))
+ status, headers, _content = binary_content(model='res.partner', id=partner_id, field='image_medium', default_mimetype='image/png', env=request.env(user=SUPERUSER_ID))
# binary content return an empty string and not a placeholder if obj[field] is False
if _content != '':
content = _content